xcode - Why the UIButton is so big in a simulator? -
i have uipageviewcontroller , uibutton under it. here screenshot of storyboard.
when build app, button huge:
all of constraints set automatically. tried specify height, doesn't help. ideas?
p.s. i'm using xcode 6.3.
edit:
viewcontroller.swift:
import uikit class viewcontroller: uiviewcontroller, uipageviewcontrollerdatasource { @iboutlet weak var restartbutton: uibutton! var pageviewcontroller: uipageviewcontroller! var pagetitles: nsarray! var pageimages: nsarray! override func viewdidload() { super.viewdidload() self.pagetitles = nsarray(objects: "page 1", "page 2") self.pageimages = nsarray(objects: "algorithm", "apoint") self.pageviewcontroller = self.storyboard?.instantiateviewcontrollerwithidentifier("pageviewcontroller") as! uipageviewcontroller self.pageviewcontroller.datasource = self var startvc = self.viewcontrolleratindex(0) contentviewcontroller var viewcontrollers = nsarray(object: startvc) self.pageviewcontroller.setviewcontrollers(viewcontrollers [anyobject], direction: .forward, animated: true, completion: nil) self.pageviewcontroller.view.frame = cgrectmake(0, 0, self.view.frame.width, self.view.frame.size.height - restartbutton.frame.height) self.addchildviewcontroller(self.pageviewcontroller) self.view.addsubview(self.pageviewcontroller.view) self.pageviewcontroller.didmovetoparentviewcontroller(self) self.view.sendsubviewtoback(self.pageviewcontroller.view) } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } func viewcontrolleratindex(index: int) -> contentviewcontroller { if ((self.pagetitles.count == 0) || (index >= self.pagetitles.count)) { return contentviewcontroller() } var vc: contentviewcontroller = self.storyboard?.instantiateviewcontrollerwithidentifier("contentviewcontroller") as! contentviewcontroller vc.imagefile = self.pageimages[index] as! string vc.titletext = self.pagetitles[index] as! string vc.pageindex = index return vc } @ibaction func restartaction(sender: anyobject) { var startvc = self.viewcontrolleratindex(0) contentviewcontroller var viewcontrollers = nsarray(object: startvc) self.pageviewcontroller.setviewcontrollers(viewcontrollers [anyobject], direction: .forward, animated: true, completion: nil) } func pageviewcontroller(pageviewcontroller: uipageviewcontroller, viewcontrollerbeforeviewcontroller viewcontroller: uiviewcontroller) -> uiviewcontroller? { var vc = viewcontroller as! contentviewcontroller var index = vc.pageindex int if (index == 0) || (index == nsnotfound) { return nil } index-- return self.viewcontrolleratindex(index) } func pageviewcontroller(pageviewcontroller: uipageviewcontroller, viewcontrollerafterviewcontroller viewcontroller: uiviewcontroller) -> uiviewcontroller? { var vc = viewcontroller as! contentviewcontroller var index = vc.pageindex int if index == nsnotfound { return nil } index++ if index == self.pagetitles.count { return nil } return self.viewcontrolleratindex(index) } func presentationcountforpageviewcontroller(pageviewcontroller: uipageviewcontroller) -> int { return self.pagetitles.count } func presentationindexforpageviewcontroller(pageviewcontroller: uipageviewcontroller) -> int { return 0 } }
i'm going guess problem have constraint top of button else in interface. rid of constraint. constraints need button @ bottom of screen bottom , right-or-left-or-center - width , height automatic.
Comments
Post a Comment