0
这是一个非常简单的问题,我想知道如何通过按下按钮在故事板之间切换。我知道如何从按钮获得输入。Xcode(iOS) - 使用按钮来切换故事板
- (IBAction)button:(id)sender {
//Code goes here
}
所有我需要知道的是,是允许我切换故事板之间的代码。
任何帮助表示赞赏。
这是一个非常简单的问题,我想知道如何通过按下按钮在故事板之间切换。我知道如何从按钮获得输入。Xcode(iOS) - 使用按钮来切换故事板
- (IBAction)button:(id)sender {
//Code goes here
}
所有我需要知道的是,是允许我切换故事板之间的代码。
任何帮助表示赞赏。
定义enum
这样的:
typedef NS_ENUM(NSInteger, StoryBordType) {
StoryBordTypeA = 0,
StoryBordTypeB,
StoryBordTypeC
};
然后你就可以定义几个类级别的属性:
@property (nonatomic, strong) UIStoryboard *storyboard;
@property (nonatomic, assign) StoryBordType currentStoryBoard;
最后,实现您的按钮操作的处理程序是这样的:
- (IBAction)button:(id)sender {
switch (self.currentStoryBoard) {
case StoryBordTypeA:
self.storyboard = [UIStoryboard storyboardWithName:@"StoryBordTypeB" bundle:nil];
self.currentStoryBoard = StoryBordTypeB;
break;
case StoryBordTypeB:
self.storyboard = [UIStoryboard storyboardWithName:@"StoryBordTypeC" bundle:nil];
self.currentStoryBoard = StoryBordTypeC;
break;
case StoryBordTypeC:
self.storyboard = [UIStoryboard storyboardWithName:@"StoryBordTypeA" bundle:nil];
self.currentStoryBoard = StoryBordTypeA;
break;
default:
break;
}
}
https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIStoryboard_类/ index.html中#// apple_ref/OCC/CLM/UIStoryboard/storyboardWithName:束: –