没有故事板的示例:
AppDelegate.h
@property (retain, nonatomic) UIViewController *leftController;
Run Code Online (Sandbox Code Playgroud)
AppDelegate.m
self.leftController = [[LeftViewController alloc] initWithNibName:@"LeftViewController" bundle:nil];
Run Code Online (Sandbox Code Playgroud)
OtherViewController:
//This is what I want do to in storyboards
self.viewDeckController.leftController = (AppDelegate*)[[UIApplication sharedApplication] delegate].leftController;
Run Code Online (Sandbox Code Playgroud)
在使用故事板时如何获取leftController的实例?
我写:
#define IS_IPHONE_5 ([UIScreen mainScreen].bounds.size.height == 568.0)
#ifdef IS_IPHONE_5
#define SCREEN_HEIGHT 568
#else
#define SCREEN_HEIGHT 480
#endif
Run Code Online (Sandbox Code Playgroud)
但它总是返回该设备是iPhone 5 ...我做错了什么?
我想当用户从左到右标签计数器从1到5更新时.如果我慢慢地滑动,非常缓慢地工作,然后更快,它不能正常工作?还有其他方法可以实现吗?
我有这个代码:
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
gestureStartPoint = [touch locationInView:self.view];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint currentPosition = [touch locationInView:self.view];
if ((int)(currentPosition.x)%40 == 0 && counter < 5) {
counter++;
}
[label setText:[NSString stringWithFormat:@"%d", counter]];
}
Run Code Online (Sandbox Code Playgroud) iphone ×3
ios ×2
counter ×1
height ×1
if-statement ×1
instance ×1
preprocessor ×1
slide ×1
touchesmoved ×1
uistoryboard ×1