小编nar*_*ner的帖子

将UIPickerView添加到UITableViewCell

我想将UIPickerView添加到UITableViewCell.现在我只是得到一个黑色的窗户.有人还可以向我解释将UI对象子类化到单元格的概念,即:我们何时将我们的单元格作为委托和数据源委托?谢谢

编辑:这是我现在正在做的代码

 case 1:  {
        cell = [tableView dequeueReusableCellWithIdentifier:@"groups"];
        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"groups"];
        }
            /*NSString *myGroupDetail = [_groupArray objectAtIndex:indexPath.row];
            NSLog(@"the group detail label is %@",myGroupDetail);
            cell.textLabel.text = myGroupDetail;
            */
        [cell addSubview:_groupPicker];

        break;

    }
Run Code Online (Sandbox Code Playgroud)

这些组是我想要选择器视图的部分,我从数组中获取数据. 这是我想要实现的

iphone xcode storyboard uitableview uipickerview

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

定时器不重复(Grand Central Dispatch)

我正在尝试学习如何在后台线程上调度计算,然后更新UI.当我在使用谷歌地图的现有项目中尝试此操作时,"背景"后跟"主"打印一次.不再进行打印,就好像计时器不重复一样.

此外,当我创建一个空白的应用程序并添加此代码时,根本没有任何打印.

let queue = dispatch_queue_create("myTimer", nil);
let timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
dispatch_source_set_timer(timer, DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC, 1 * NSEC_PER_SEC);

dispatch_source_set_event_handler(timer) {
    println("background")
    dispatch_async(dispatch_get_main_queue(), { println("main") })
}

dispatch_resume(timer)
Run Code Online (Sandbox Code Playgroud)

xcode nstimer grand-central-dispatch ios swift

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

使用Autolayout基于宽度比设置UIImage高度

我想弄清楚如何根据宽度在故事板上设置UIimage的高度?我需要它是基于宽度的比率.所以图像是全宽的.

目前我正在使用通用故事板,并希望图像为3:4,因此高度需要比宽度大33%.

我不明白的是通用故事板上的宽度是600,那么我怎么得到高度比宽度大33%的比例?

我无法弄清楚如何做到这一点.

ios uistoryboard autolayout

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

使用MapKit和CoreLocation时出现Xcode警告

我正在尝试使用实现一个实例MKMapView,用于CoreLocation跟踪用户位置,然后放大它们的位置.

我只想在我处于前台时跟踪用户的位置.由于我的应用程序是针对iOS8的,因此我有一个密钥的plist条目NSLocationWhenInUseUsageDescription.

当我第一次运行应用程序时,应用程序会相应地询问它是否可以访问我的位置.单击"允许"后,我会从Xcode收到以下警告:

Trying to start MapKit location updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first.

......这实际上有点令人困惑,正如我在requestWhenInUseAuthorization下面的代码中可以看到的那样:

@property (strong, nonatomic) IBOutlet MKMapView *mapView;
@property(nonatomic, retain) CLLocationManager *locationManager;

@end

@implementation MapView

- (void)viewDidLoad {
    [super viewDidLoad];
    [self locationManager];
    [self updateLocation];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    self.locationManager = nil;
}

- (CLLocationManager *)locationManager {
    //We only want to get the location when the app is in the …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c core-location mkmapview ios

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