小编Ida*_*she的帖子

从未调用subscriberCellularProviderDidUpdateNotifier

以下代码:

CTTelephonyNetworkInfo *info = [[CTTelephonyNetworkInfo alloc] init];
    info.subscriberCellularProviderDidUpdateNotifier = ^(CTCarrier *carrier) {
        dispatch_async(dispatch_get_main_queue(), ^{
            NSLog(@"User did change SIM");
        });
    };
Run Code Online (Sandbox Code Playgroud)

内:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Run Code Online (Sandbox Code Playgroud)
  • 或者无论我把代码放在哪里来测试它.

无论我用iSO 7.1.1取代iPad Air Mini Wifi + 3G有多少SIM卡,这个活动都没有被调用.

我究竟做错了什么?

objective-c ios core-telephony

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

是否有可能获得PID的启动时间?

我有一段代码在这里漂浮了一段时间(代码对我有用):

- (NSArray *) runningProcesses {
    //CTL_KERN?KERN_PROC,KERN_PROC_ALL
    int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL ,0};
    size_t miblen = 4;

    size_t size;
    int st = sysctl(mib, miblen, NULL, &size, NULL, 0);

    struct kinfo_proc * process = NULL;
    struct kinfo_proc * newprocess = NULL;
    do {
        size += size / 10;
        newprocess = realloc(process, size);
        if (!newprocess) {
            if (process) {
                free(process);
                process = NULL;
            }
            return nil;
        }
        process = newprocess;
        st = sysctl(mib, miblen, process, &size, NULL, 0);
    } while (st …
Run Code Online (Sandbox Code Playgroud)

c pid process objective-c ios

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

在自定义UITableViewCell中解除UITextField的问题

我在表视图中实现了一个自定义单元格.在单元格内部,我有一个文本字段(设置为数字键盘键盘).在表格视图中我有12个单元格.我可以touchesBegan使用自定义单元类中的代码来调用键盘(虽然只有当我点击我正在编辑的活动单元时才有效).如果我将键盘更改为字母和数字,我也可以关闭键盘.我在键盘上有一个自定义的"DONE"按钮,我希望它能解除文本字段.

我已经尝试了一段时间用endEditing:YES或解除键盘,[cell.textFieldAnswer resignFirstResponder]但它不起作用.

有任何想法吗?

SecurityQuestions.m:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {
        cell = [[GetQuestionsCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }


    NSInteger nextIndexPathRow = indexPath.row;
    nextIndexPathRow++;
    cell.labelQuestion.text = [arrayOfQuestions objectAtIndex:indexPath.row];
    cell.labelQuestionNumber.text = [NSString stringWithFormat:@".%d", nextIndexPathRow];

    switch (indexPath.row) {
        case 0:
            tfA1 = (UITextField*)[cell viewWithTag:nextIndexPathRow];
            break;
        case 1:
            tfA2 = (UITextField*)[cell viewWithTag:nextIndexPathRow];
            break;
        case 2:
            tfA3 = (UITextField*)[cell viewWithTag:nextIndexPathRow];
            break; …
Run Code Online (Sandbox Code Playgroud)

keyboard uitableview uitextfield dismiss ios

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

将双值保存到核心数据有时可以节省完全错误的值

我正在通过2个双倍值(distance,distanceToClosePoint)更新核心数据实体.一些数据以错误的值保存,结果在我的应用程序中完全混乱.

第一:

- (void)updateTrapDistance:(double)distance trapID:(int)trapID distanceToClosePoint:(double)distanceToClosePoint
{
    NSManagedObjectContext *context = generateManagedObjectContext();

NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:kCORE_DATA_ALL_TRAPS_ENTITY inManagedObjectContext:context];
[fetchRequest setEntity:entity];

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"trapID.intValue==%i", trapID];
[fetchRequest setPredicate:predicate];

NSError *error = nil;
NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:&error];
if (fetchedObjects == nil || fetchedObjects.count == 0) {
    NSLog(@"%s error saving: %@\n%@", __PRETTY_FUNCTION__, error.localizedDescription, error.userInfo);

    return;
}

CoreDataAllTraps *trap = fetchedObjects.firstObject;
[trap setDist:[NSNumber numberWithInt:distance]];
[trap setDist_to_close_point:[NSNumber numberWithInt:distanceToClosePoint]];

if(![context save:&error]) {
    NSLog(@"%s error saving: %@\n%@", __PRETTY_FUNCTION__, error.localizedDescription, …
Run Code Online (Sandbox Code Playgroud)

core-data objective-c ios

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

使用公共/非公共/私有API在设备上获得顶级UIWIndow/UIView

我试图找出如何找到利用非公开/私有API最顶部的视图,有没有什么办法做这件事(的iOS 7.1.2)?

编辑:

也许我不清楚,无论现在哪个应用程序处于活动状态(facebook,whatsapp,游戏,锁屏,日历等),我都希望得到最顶级的视图.

objective-c ios

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

在自定义单元格(xib)中滚动时,UITextField中的文本消失

我已经阅读了很多关于我的问题,但我仍然无法指出确切的问题.我已经尝试了一些如果这里的代码在堆栈,但它我一直在收到错误.下面的代码有效,但在滚动时消失了文本.

有任何想法吗?

GetQuestionsCustomCell.h:

@interface GetQuestionsCustomCell : UITableViewCell <UITextFieldDelegate>

@property (strong, nonatomic) IBOutlet UILabel *labelQuestion;
@property (strong, nonatomic) IBOutlet UITextField *textFieldAnswer;
@property (strong, nonatomic) IBOutlet UILabel *labelQuestionNumber;
- (IBAction)KeyDown:(id)sender;

@end
Run Code Online (Sandbox Code Playgroud)

GetQuestionsCustomCell.m:

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        NSArray *nibArray = [[NSBundle mainBundle] loadNibNamed:@"GetQuestionsCustomCell" owner:self options:nil];
        self = [nibArray objectAtIndex:0];
        self.textFieldAnswer.delegate = self;
    }
    return self;
}
Run Code Online (Sandbox Code Playgroud)

SecurityQuestions.m:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    GetQuestionsCustomCell *cell …
Run Code Online (Sandbox Code Playgroud)

uitableview ios

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

'[UITabBar外观] setTitle' - 在Xcode 5,iOS 7中不起作用

Xcode的5甚至没有熟悉setTitleUITabBar,错误的是:

'UITabBar'没有可见的@interface声明选择器'setTitle:

寻找UITabBar:http://developer.apple.com/library/ios/navigation/未显示版本的任何变化.这里发生了什么?

编辑:

原始代码是:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        [[UITabBar appearance] setBackgroundImage:[[UIImage alloc]init]];
        [[UITabBar appearance] setSelectionIndicatorImage:[[UIImage alloc]init]];
        [[UITabBar appearance] setTitle:NSLocalizedString(@"home", nil)];
    }
    return self;
}
Run Code Online (Sandbox Code Playgroud)

objective-c uitabbar uiappearance ios7 xcode5

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

目标 c 的四叉树或 KD 树?

我正在寻找一段合适的代码在我的应用程序中使用,在其中一个算法中。我找到了这个例子: http: //rosettacode.org/wiki/K-d_tree#C 但是当我将代码放入 xcode 中时,我收到错误,例如:

“使用未声明的标识符”,“预期为‘;’ 声明末尾”。我猜是缺少头文件吗?

c objective-c quadtree kdtree

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

如何在UIView中制作可扩展的环形动画(类似于潜艇声纳)?

我想知道如何制作像潜水艇中的声纳一样的动画:从中心扩展的厚环,当alpha降到0时变得更大并消失; 我讲了一些关于CABasicAnimation的例子,但是我不知道如何做这个动画片.

animation objective-c ios

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

拦截iOS中的来电(不接听状态)

我试图找出如何在收到电话时拦截,没有人接听,然后转到语音邮件.我查看了CTCall和CTCallCenter,但我不确定他们是否没有回答我的问题,或者不允许应用程序进入AppStore.有想法/想法吗?

ios core-telephony

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

格式化日期为NSDate

我有一个像这样的NSDateFormatter:

YYYY/MM/dd HH:mm:ss

我可以从转换NSDateNSStringNSStringNSDate.但我想要的是在格式化时获取NSDate.我想把它转换成NSString然后转换回来,NSDate但这种方式很可怕,我确信有一种更简单的方法,对吧?

objective-c nsdate ios

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