小编B.S*_*.S.的帖子

UITableViewCell分隔符在iOS7中消失

UITableView只有在iOS 7中有一些奇怪的问题.

UITableViewCellSeparator消失在第一行上方和最后一行下方.有时在选择行或某些滚动操作后会出现.

在我的情况下tableView是从StoryboardUITableViewStylePlain样式加载.问题肯定不在UITableViewCellSeparatorStyle,默认情况下没有改变UITableViewCellSeparatorStyleSingleLine.

正如我在Apple Dev论坛上所读到的(这里这里),其他人有这样的问题,并找到了一些解决方法,例如:

Workaround: disable the default selection and recreate the behaviour in a method
trigged by a tapGestureRecognizer.
Run Code Online (Sandbox Code Playgroud)

但我仍在寻找这种分隔符奇怪行为的原因.

有任何想法吗?

更新:正如我在XCode 5.1 DP和iOS 7.1 beta中看到的那样,Apple试图解决这个问题.现在,在一些刷新之后,有时需要在最后一行的下方显示分隔符,但不是在创建tableview之后.

cocoa-touch objective-c uitableview uikit ios

129
推荐指数
8
解决办法
5万
查看次数

iOS7中的UIAlertView addSubview

添加一些控件UIAlertView已在iOS7中使用addSubview方法弃用.据我所知,Apple承诺增加contentView财产.

iOS 7现已发布,我发现此属性未添加.这就是为什么我搜索一些能够为此alertView添加进度条的自定义解决方案.例如类似于TSAlertView的东西,但更适合在iOS 7中使用.

objective-c uialertview ios ios7

67
推荐指数
6
解决办法
9万
查看次数

如何使UIView动画序列重复和自动反转

如何使这个复杂的动画重复和自动反转?有没有办法添加选项UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat到这个动画序列?

   [UIView animateWithDuration:1.0f animations:^{

        someView.frame = someFrame1;

    } completion:^(BOOL finished) {

        [UIView animateWithDuration:0.5f animations:^{

            someView.frame = someFrame2;

        } completion:nil];

    }];
Run Code Online (Sandbox Code Playgroud)

objective-c uiview uiviewanimation ios

35
推荐指数
2
解决办法
5万
查看次数

主线程中的di​​spatch_get_main_queue()

我有一些方法可以在某些情况下改变UI.

例如:

-(void) myMethod {

  if(someExpressionIsTrue) {
    // make some UI changes
    // ...
    // show actionSheet for example
  }
}
Run Code Online (Sandbox Code Playgroud)

有时从某些人那里myMethod调用.mainThreadother thread

这就是为什么我希望这些UI更改可以肯定地执行mainThread.

我改变了myMethod这种方式所需的部分:

if(someExpressionIsTrue) {
     dispatch_async(dispatch_get_main_queue(), ^{
        // make some UI changes
        // ...
        // show actionSheet for example
      });
}
Run Code Online (Sandbox Code Playgroud)

所以问题:

  • dispatch_async(dispatch_get_main_queue() 在主线程中调用是否安全且良好的解决方案?它会影响性能吗?
  • 这个问题可以用另一种更好的方式解决吗?我知道我可以检查它是否是一个使用[NSThread isMainThread]方法的主线程,并且dispatch_async仅在其他线程的情况下调用,但它将使我再创建一个方法或阻止这些UI更新.

multithreading objective-c nsthread grand-central-dispatch

25
推荐指数
2
解决办法
4万
查看次数

旋转后如何让UIPopoverController保持相同的位置?

旋转后我无法在屏幕上保持弹出相同的位置.有没有什么好方法可以做到这一点,因为只是设置一些框架到弹出窗口旋转后工作很糟糕.popover.frame = CGRectMake(someFrame);旋转弹出后,只有当它位于屏幕的中心时才会看起来很好.

objective-c uipopovercontroller autorotate ios uipopover

21
推荐指数
4
解决办法
2万
查看次数

手势识别器不适用于子视图

首先,我将UISwipeGestureRecognizer附加到图像视图,无法触发操作方法.然后我附加UISwipeGestureRecognizer来查看控制器的视图,它运行良好.我不知道为什么.这是不起作用的代码

 - (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    UISwipeGestureRecognizer *swipeRight=[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRightAction)];
    swipeRight.direction=UISwipeGestureRecognizerDirectionRight;
    //imageView is an outlet of image view
    [imageView addGestureRecognizer:swipeRight];
}
Run Code Online (Sandbox Code Playgroud)

这是运行良好的代码

- (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view.

    UISwipeGestureRecognizer *swipeRight=[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRightAction)];
    swipeRight.direction=UISwipeGestureRecognizerDirectionRight;
    //imageView is an outlet of image view
    [self.view addGestureRecognizer:swipeRight];
}
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c ipad ios

13
推荐指数
1
解决办法
5570
查看次数

如何在box2d中检测碰撞但不碰撞?

如何检测身体是否与其他身体发生碰撞但对此碰撞没有反应.

通过默认的 I -碰撞检测和机构碰撞.

如果我设置fixtureDef过滤器 - 主体不会发生碰撞,但我无法检测到碰撞.

请帮忙!

c++ collision box2d

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

UIAlertController从UIBarButtonItem呈现,旋转后位置错误

我有UIToolBar一些按钮.我目前UIAlertController使用UIAlertControllerStyleActionSheet该按钮的演讲风格.它显示正确,但是当我旋转设备时,此操作表有错误的位置.

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];

UIAlertAction* destructive = [UIAlertAction actionWithTitle:destructiveTitle style:UIAlertActionStyleDestructive handler:someHandler];
[alertController addAction:destructive];

[alertController setModalPresentationStyle:UIModalPresentationPopover];
alertController.modalInPopover = YES;

alertController.popoverPresentationController.barButtonItem = barButton;

alertController.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionAny;

alertController.popoverPresentationController.delegate = self;

[self presentViewController:alertController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

还有一两件事在这里,popoverPresentationController:willRepositionPopoverToRectUIPopoverPresentationControllerDelegate没有叫我时,旋转装置.

这里出了什么问题,有什么建议吗?

提前致谢!

ios8 uialertcontroller

10
推荐指数
0
解决办法
3434
查看次数

如何在UINavigationController上添加视图?

嗨,我想知道如何放置一个视图,使其覆盖整个UINavigationController.基本上我想在视图中添加一个0.5 alpha黑色叠加层,使其具有"禁用"外观.我试图介绍的UINavigationController是iPad上拆分视图控制器的DetailViewController.

我知道我可以将视图作为子视图添加到导航控制器根视图,但不会覆盖顶部的导航栏.

iphone cocoa-touch objective-c ipad ios

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

正确存储应用程序内购买

是否有任何建议如何存储应用内购买结果.

我使用raywenderlich教程购买

它将结果存储到NSUserDefaults.

所以问题:将应用内结果存储为bool值是否安全NSUserDefaults.因为每个人都可以查看Library/Preferences文件夹,看看那里写的是什么.

iphone objective-c nsuserdefaults in-app-purchase ios

7
推荐指数
1
解决办法
732
查看次数