小编133*_*ode的帖子

获取View Controller的StoryBoard实例

没有故事板的示例:

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的实例?

iphone instance uiviewcontroller ios uistoryboard

9
推荐指数
1
解决办法
2万
查看次数

#ifdef检查设备是否为iPhone 5

我写:

#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 ...我做错了什么?

iphone height preprocessor if-statement

3
推荐指数
1
解决办法
3885
查看次数

touchesMoved工作不够快

我想当用户从左到右标签计数器从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 counter slide touchesmoved ios

0
推荐指数
1
解决办法
562
查看次数