I have a problem when I create a list inside a tabbar. the list is positioned above the tabbar. this is my code:
--in my .lua :
local ui = require("ui")
local viewController = require("viewController")
------Grupos--------
local mainView = display.newGroup()
----Variables Globales----
local currentScene
local tabView
local tabBar
local firstRun = true
-----Funciones--------
local function loadScene(scene)
if currentScene then
currentScene:cleanUp()
end
currentScene = require(scene).new()
tabView:insert(currentScene)
end
local function showScreen(event)
local t = event.target
local phase = event.phase
if phase == "ended" then
if t.id == 1 then
loadScene("home1")
elseif t.id == 2 then
print("hom2")
loadScene("hom2")
elseif t.id == 3 then
loadScene("hom3")
elseif t.id == 4 then
loadScene("hom4")
elseif t.id == 5 then
loadScene("hom5")
end
tabBar.selected(t)
end
return true
end
function new()
mainView = display.newGroup()
tabView = display.newGroup()
mainView:insert(tabView)
loadScene("home")
tabBar = viewController.newTabBar{
background = "tabBar.png", --tab bar background
tabs = {"home", "home2", "home3","home4","home5"}, --names to appear under each tab icon
onRelease = showScreen --function to execute when pressed
}
mainView:insert(tabBar)
tabBar.selected()
return mainView
end
in my home.lua
function new()
local tableView = require("tableView")
--import the button events library
local ui = require("ui")
display.setStatusBar( display.HiddenStatusBar )
local grupo = display.newGroup()
--initial values
local screenOffsetW, screenOffsetH = display.contentWidth - display.viewableContentWidth, display.contentHeight - display.viewableContentHeight
local myList, backBtn, detailScreenText
local background = display.newRect(0, 0, display.contentWidth, display.contentHeight)
background:setFillColor(0, 77, 77)
--setup a destination for the list items
--display
local detailBg = display.newRect(0,0,display.contentWidth,display.contentHeight-display.screenOriginY)
detailBg:setFillColor(255,255,255)
--grupo:insert(detailBg)
detailScreenText = display.newText("You tapped item", 0, 0, native.systemFontBold, 24)
detailScreenText:setTextColor(0, 150,50)--(,color del texto,)
----inserta en grupo------
grupo:insert(detailScreenText)
detailScreenText.x = math.floor(display.contentWidth/2)
detailScreenText.y = math.floor(display.contentHeight/2)
-------inserta en grupo------
grupo.x = display.contentWidth
--detailScreen:insert(detailScreenText)
--setup functions to execute on touch of the list view items
function listButtonRelease( event )
self = event.target
local id = self.id
print("self.id",self.id)
detailScreenText.text = "You tapped item ".. self.id
transition.to(myList, {time=400, x=display.contentWidth\*-1, transition=easing.outExpo })
transition.to(detailScreen, {time=400, x=0, transition=easing.outExpo })
transition.to(backBtn, {time=400, x=math.floor(backBtn.width/2) + screenOffsetW\*.5 + 6, transition=easing.outExpo })
transition.to(backBtn, {time=400, alpha=1 })
delta, velocity = 0, 0
end
function backBtnRelease( event )
print("back button released")
transition.to(myList, {time=400, x=0, transition=easing.outExpo })
transition.to(grupo, {time=400, x=display.contentWidth, transition=easing.outExpo })
transition.to(backBtn, {time=400, x=math.floor(backBtn.width/2)+backBtn.width, transition=easing.outExpo })
transition.to(backBtn, {time=400, alpha=0 })
delta, velocity = 0, 0
end
local topBoundary = display.screenOriginY + 40
local bottomBoundary = display.screenOriginY + 0
-- setup some data
local data = {}
for i=1, 20 do
data[i] = {}
data[i].title = "List item ".. i
local c = math.modf(i/5)
data[i].category = "Category ".. c + 1
end
--add some items that have arbitrary categories
data[1] = {}
data[1].title = "Pizza"
data[1].category = "Dinner"
data[1].subtitle = "Subtitulo"
data[5].title = "Apple Pie"
data[5].category = "Dinner"
data[4].title = "Chicken Pot Pie"
data[4].category = "Dinner"
data[2].title = "Coffee"
data[2].category = "Breakfast"
data[6].title = "Bagel"
data[6].category = "Breakfast"
data[3].title = "Cheese"
data[3].category = "Lunch"
--specify the order for the groups in each category
local headers = {"Dinner", "Breakfast", "Lunch" }
-- Create a list with header titles
myList = tableView.newList{
data=data,
default="listItemBg.png",
over="listItemBg\_over.png",
onRelease=listButtonRelease,
top=topBoundary,
bottom=bottomBoundary,
cat="category",
order=headers,
categoryBackground="catBg.png",
backgroundColor={ 255, 255, 255 },
callback=function(item)
local t = display.newText(item.title, 0, 0, native.systemFontBold, textSize)
t:setTextColor(0, 0, 0)
t.x = math.floor(t.width/2) + 12
t.y = 46
return t
end
}
--Setup the nav bar
local navBar = display.newImage("navBar.png", 0, 0, true)
navBar.x = display.contentWidth\*.5
navBar.y = math.floor(display.screenOriginY + navBar.height\*0.5)
local navHeader = display.newText("My List", 0, 0, native.systemFontBold, 16)
navHeader:setTextColor(255, 255, 255)
navHeader.x = display.contentWidth\*.5
navHeader.y = navBar.y
--Setup the back button
backBtn = ui.newButton{
default = "backButton.png",
over = "backButton\_over.png",
onRelease = backBtnRelease
}
backBtn.x = math.floor(backBtn.width/2) + backBtn.width + screenOffsetW
backBtn.y = navBar.y
backBtn.alpha = 0
function grupo:cleanUp()
grupo:removeSelf()
end
return grupo
end
I want to do this
http://iphonedevelopertips.com/images/forums/bird-app-tabbar.png [import]uid: 59020 topic_id: 18152 reply_id: 318152[/import]