小编Dan*_*ena的帖子

当活动指示器视图可见时,不允许用户交互

我有一个包含两个视图的视图.其中一个视图包含两个按钮和一些文本标签.另一个,alpha设置为0.25,有一个UIActivityIndicatorView告诉用户应用程序正在工作,他必须等到它完成.如果用户在UIActivityIndicatorView旋转时触摸按钮,则当UIActivityIndicatorView停止时,应用记住用户操作并响应它.如何丢弃UIActivityIndicatorView正在旋转时发生的用户交互?

谢谢阅读.

PD:就像在这个帖子中评论一样,我更喜欢不使用任何模态解决方案.

编辑:

我目前正在使用此代码,但它无法正常工作.

- (void)viewDidAppear:(BOOL)animated {

  // The view appears with an UIActivityIndicatorView spinning.
  [self showResults]; // The method that takes a long time to finish.
  [self.activityIndicator stopAnimating];
  // When the showResults method ends, the view shows the buttons to the user.
  [self.activityIndicatorView setHidden:YES];
  [self.menuButton setEnabled:YES];
  [self.menuButton setUserInteractionEnabled:YES];
  [self.playButton setEnabled:YES];
  [self.playButton setUserInteractionEnabled:YES];
  [self.view setUserInteractionEnabled:YES];
  [self.interactionView setUserInteractionEnabled:YES];
}
Run Code Online (Sandbox Code Playgroud)

objective-c user-interaction uiactivityindicatorview ios

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

检查iOS位置服务

我有一个带有地图和按钮的视图(比如地图应用程序一次),允许用户在地图上居中和缩放他当前的位置.如果我不能使用locationServicesEnabled方法(总是返回YES),我应该创建一个BOOL属性来检查是否调用了didFailWithError方法并知道我是否可以调用button方法?

谢谢阅读.

编辑:

此代码对我不起作用.我正在使用模拟器.在询问locationServicesEnabled时,我总是得到YES.

// Gets the user present location.
- (IBAction)locateUser:(id)sender {

    if([CLLocationManager locationServicesEnabled]) {

        CLLocationCoordinate2D coordinate;

        coordinate.latitude = self.mapView.userLocation.location.coordinate.latitude;
        coordinate.longitude = self.mapView.userLocation.location.coordinate.longitude;

        [self zoomCoordinate:coordinate];
    } else {
        [[[[UIAlertView alloc] initWithTitle:@"Warning." message:@"Location services are disabled." 
                                    delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease] show];     
    }
}
Run Code Online (Sandbox Code Playgroud)

objective-c cllocationmanager ios

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

获得黑白UIImage(非灰度)

我需要从另一个UIImage(不是灰度)获得纯黑白UIImage.有人可以帮帮我吗?

谢谢阅读.

编辑:

这是建议的解决方案.谢谢大家.几乎我知道这不是更好的方法,它工作正常.

// Gets an pure black and white image from an original image.
- (UIImage *)pureBlackAndWhiteImage:(UIImage *)image {

    unsigned char *dataBitmap = [self bitmapFromImage:image];

    for (int i = 0; i < image.size.width * image.size.height * 4; i += 4) {

        if ((dataBitmap[i + 1] + dataBitmap[i + 2] + dataBitmap[i + 3]) < (255 * 3 / 2)) {
            dataBitmap[i + 1] = 0;
            dataBitmap[i + 2] = 0;
            dataBitmap[i + 3] = 0;
        } else { …
Run Code Online (Sandbox Code Playgroud)

image-processing uiimage ios

5
推荐指数
3
解决办法
8926
查看次数

iOS上最好的广告平台

我已将iAd添加到我的应用程序中,但我读过这不是iOS上最好的广告平台.我必须将其更改为其他选项,例如AdWhirl或适用于iOS的Google Ads SDK.什么是最有利可图的选择?(我的应用程序是导游)

谢谢阅读.

ads ios

4
推荐指数
1
解决办法
2294
查看次数

将Cell Text重新打印到UITableViewCell中

进入类的cellForRowAtIndexPath:方法UITableViewController我正在使用下一个代码来显示包含一个的单元格UITextView.

有时当我滚动包含单元格的表格然后滚动单元格时UITextView,它会显示重新打印的单元格文本(好像有两个UITextView对象,而不是一个,进入单元格).

我该怎么做才能解决这个问题?

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];    
if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

cell.contentView.bounds = CGRectMake(0, 0, cell.frame.size.width, cell.frame.size.height);
cell.selectionStyle = UITableViewCellSelectionStyleNone;

UITextView *textView = [[UITextView alloc] initWithFrame:cell.contentView.bounds];
                textView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
textView.editable = NO;
textView.scrollEnabled = YES;
textView.backgroundColor = [UIColor clearColor];
textView.font = [UIFont fontWithName:@"Helvetica" size:14.0];
textView.text = self.description;

[cell.contentView addSubview:textView];
[textView release];
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview ios

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