죄송합니다. Swift 2를 사용 중이며 여전히 newb입니다. 내가 프로그래밍의 UITabBar을 만들 수있게되었습니다하고있는 UIWebView는 다음 코드를 사용하여 :프로그래밍 방식으로 생성 된 Uiabbar의 콘텐츠를 프로그래밍 방식으로 생성 된 UITabBar에서 변경하기
//Mapping Tab Bar Buttons
func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem) {
if item.tag == 1 {
self.myWebView.loadRequest(NSURLRequest(URL: NSURL(string:"https://www.ustream.tv/combined-embed/10786920?social=0&videos=gallery&videosCount=4&html5ui")!))
} else if item.tag == 2 {
self.myWebView.loadRequest(NSURLRequest(URL: NSBundle.mainBundle().URLForResource ("index", withExtension: "htm")!))
} else if item.tag == 3 {
self.myWebView.loadRequest(NSURLRequest(URL: NSBundle.mainBundle().URLForResource ("Agenda", withExtension: "html")!))
} else if item.tag == 4 {
print("ApplePay")
} else if item.tag == 5 {
print("Bulletin")
}
}
어느 버튼 네다섯을 누르면 : 다음을 누르면하는 "버튼"식별이 코드를 사용
class ViewController: UIViewController, UIToolbarDelegate, UITabBarDelegate {
@IBOutlet var myWebView: UIWebView!
@IBOutlet weak var tabbar: UITabBar!
// @IBOutlet weak var myWebView:UIWebView! = UIWebView(frame: CGRectMake(0, 60, UIScreen.mainScreen().bounds.width, UIScreen.mainScreen().bounds.height - 112))
override func viewDidLoad() {
super.viewDidLoad()
//Add Webview
let myWebView:UIWebView = UIWebView(frame: CGRectMake(0, 60, UIScreen.mainScreen().bounds.width, UIScreen.mainScreen().bounds.height - 112))
myWebView.loadRequest(NSURLRequest(URL: NSBundle.mainBundle().URLForResource ("index", withExtension: "htm")!))
self.view.addSubview(myWebView)
//Add Toolbar for menu
let toolbar = UIToolbar()
toolbar.frame = CGRectMake(0, 20, self.view.frame.size.width, 46)
toolbar.sizeToFit()
// make a button
let menuButton: UIBarButtonItem = UIBarButtonItem(image: UIImage(named: "list-fat-7.png"), style:.Plain, target: self, action: "twitter")
menuButton.tag = 1
toolbar.items = [menuButton]
//set toolbar color toolbar.backgroundColor = UIColor.redColor()
self.view.addSubview(toolbar)
//Add Tab Bar
let tabBar = UITabBar()
tabBar.delegate = self
tabBar.frame = CGRectMake(0, self.view.frame.size.height - 52, self.view.frame.size.width, 52)
tabBar.sizeToFit()
// Tab Bar buttons
let sermonButton = UITabBarItem(title: "Sermons", image: UIImage(named: "video-camera-7.png"), selectedImage: UIImage(named: "video-camera-7.png"))
sermonButton.tag = 1
let bibleButton = UITabBarItem(title: "Bible", image: UIImage(named: "book-cover-7.png"), selectedImage: UIImage(named: "book-cover-7.png"))
bibleButton.tag = 2
let calendarButton = UITabBarItem(title: "Calendar", image: UIImage(named: "calendar-7.png"), selectedImage: UIImage(named: "calendar-7.png"))
calendarButton.tag = 3
let givingButton = UITabBarItem(title: "Giving", image: UIImage(named: "gift-7.png"), selectedImage: UIImage(named: "gift-7.png"))
givingButton.tag = 4
let bulletinButton = UITabBarItem(title: "Bulletin", image: UIImage(named: "newspaper-7.png"), selectedImage: UIImage(named: "newspaper-7.png"))
bulletinButton.tag = 5
tabBar.items = [sermonButton,bibleButton,calendarButton,givingButton,bulletinButton]
self.view.addSubview(tabBar)
}
을 해당 메시지를 인쇄하지만 다른 버튼을 누르면 "치명적인 오류 : 선택적 값 (lldb)을 래핑하는 동안 예기치 않게 오류가 발생했습니다"오류가 반환됩니다. 나는 func TabBar에서 자기를 추가하고 제거함으로써이 문제를 해결하려고 노력했다. 누구든지 내 실수를 볼 수 있습니까? 어떤 도움을 주시면 감사하겠습니다. 저 후에 수행하는 사람들 있도록