小编Mus*_*afa的帖子

iPhone开发 - iphone应用程序的内存限制

任何人都可以在这里指出正确的方向.我希望在我的应用程序收到内存警告时响应(我想知道如何响应此通知).另外,我可以用我的应用程序连接多少内存?

任何文章或书籍参考都会很棒.谢谢.

memory iphone

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

UITextView放入UITableViewCell时有时不显示内容

我想知道是否还有其他人面临同样的问题.我在UITableViewCell中放置了一个UITextView字段.有时它不显示文本.当我单击或滚动表格视图时,它会出现.任何猜测?


细节:

我在viewDidLoad方法中调用一个方法,该方法调用Web服务来检索一些数据.收到数据后,我设置了UILabelUITextView的值.UILabel值显示正常,但UITextView(有时)在我移动到子视图或向上和向下滚动以重新访问包含UITextView的区域之前不会显示该值.我在UITableViewCell中显示UILabelUITextView对象.我在UILabelUITextView中设置值后立即调用[tableView reloadData],但我不重新创建UITableViewCell.

感谢您的回复和指示.

cocoa-touch

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

iPhone开发 - 模拟内存警告

背景:

我有一个标签栏应用程序.每个选项卡都包含导航控制器,允许用户从一个视图转换到另一个视图,显示数据的向下钻取信息(每个视图由视图控制器处理,每个视图控制器类都有didReceiveMemoryWarning方法).通过从Web服务中提取数据来填充列表.

问题:

当我使用iPhone模拟器的"硬件>模拟内存警告"选项时,didReceiveMemoryWarning将为所有视图控制器调用该方法 - 即使是用户正在查看的控制器.我不想清除活动视图控制器正在使用的任何内容.我怎样才能做到这一点?

由于内存警告,在数据发布后,哪种方法应该重新加载数据?(我看到viewDidLoad当用户返回到该视图时,包含表视图调用方法的视图控制器类,但如果视图包含(比如UIWebView),viewDidLoad则不调用方法.为什么会这样?)

编辑(2009年1月30日星期五 - 03:10 PM)

(注意:我正在使用"界面"构建器来创建视图,并且loadView方法已被注释掉.)

因此,当视图控制器收到内存警告消息时,这些是执行的步骤:

  1. 以下方法称为:

    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning]; 
    }
    
    Run Code Online (Sandbox Code Playgroud)
  2. 由于调用[super didReceiveMemoryWarning],[self setView:nil]自动调用?

  3. 如果应清除任何资源,setView则应覆盖方法以清除本地资源.

  4. [self setView:nil]如果视图当前处于活动状态,则不会调用(默认情况下).对? - 我真的很好奇哪种方法可以做出这个决定以及如何做出决定?

可以请你确认一下.另外,我在这种方法myObject = nil后遇到错误,但myObjectdealloc控制器类的方法中释放后添加修复了问题.谢谢.

memory iphone warnings simulator

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

iPhone开发 - CLLocationManager与MapKit

如果我想在地图上显示用户位置,并在同一时间记录用户的位置,它是一个好主意,添加一个观察者userLocation.location并记录位置,或者我应该仍然使用CLLocationManager用于记录用户位置和使用方法mapView.showUserLocation显示用户的当前位置(蓝色指示灯)?我想显示MapKit API支持的默认蓝色指示器.

另外,这是一个粗略的示例代码:

- (void)viewDidLoad {
    ...

    locationManager = [[CLLocationManager alloc] init]; 
    locationManager.desiredAccuracy = kCLLocationAccuracyBest; 
    locationManager.distanceFilter = DISTANCE_FILTER_VALUE;
    locationManager.delegate = self; 
    [locationManager startUpdatingLocation];

    myMapView.showUserLocation = YES;
    [myMapView addObserver:self forKeyPath:@"userLocation.location" options:0 context:nil];

    ...
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
    // Record the location information
    // ...
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { 
    NSLog(@"%s begins.", __FUNCTION__);

    // Make sure that the location returned has the desired accuracy
    if (newLocation.horizontalAccuracy <= manager.desiredAccuracy)
        return;

    // Record the …
Run Code Online (Sandbox Code Playgroud)

iphone mapkit mkmapview cllocationmanager showuserlocation

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

tableFooterView 没有在表格底部正确对齐

我遇到了一个奇怪的行为UITableView。我已经设置了UIViewController一个UITableView. UITableView包含一个tableHeaderViewtableFooterView一个节页脚视图,以及几个UITableViewCell具有动态高度的s。

问题是tableFooterView出现在表格中间的某处(悬停在单元格上),而不是在表格内容的底部对齐。显然,表的contentSize属性也返回不正确的内容大小(特别是高度)。

The custom section footer view, however, is appearing in the right place (and below the actual tableFooterView -- which is hovering in the middle of the table).

Any ideas what's going on?

Note: My custom table-view (with dynamic height handing using Auto Layouts) is showing a "Ambiguous Layout: 2 views are vertically ambiguous." warning, but it's resizing correctly at run-time. …

uitableview ios autolayout tablefooterview

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

在iOS8中没有调用UIViewController设备旋转委托方法

我一直在使用iOS 7应用程序,使其兼容ios 8(beta 5).在这个应用程序中,UIViewController(vc1)呈现另一个UIViewController(vc2).vc1支持纵向和横向方向; vc2仅支持纵向方向.当vc2被呈现,它会询问vc1:shouldAutorotateToInterfaceOrientation:这返回YES.

在iOS8(Beta 5)中willRotateToInterfaceOrientation:,didRotateFromInterfaceOrientation:并没有被调用以及新的iOS 8 API方法viewWillTransitionToSize.但是,这在iOS7中运行良好.

我知道willAnimateRotationToInterfaceOrientation并且didRotateFromInterfaceOrientation在iOS 8中被弃用,但即使是iOS 8委托方法也没有被调用.每次vc2vc1纵向启动时屏幕加载仅在纵向模式下,即使我提到支持的界面方向为横向左侧.

任何想法......这是iOS8中的一个错误吗?

ios ios8

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

为什么我不能使用UI Automation脚本访问iPhone应用程序中的Back按钮?

我有一个简单的函数,应该检查视图是否在home接口,如果没有,将它带到家里:

function returnHome() {
    if (UIATarget.localTarget().frontMostApp().navigationBar().name() == mainTitle) return true;

    // set tab bar to calculations
    UIALogger.logMessage("Set tab bar to main.");
    if (UIATarget.localTarget().frontMostApp().tabBar().selectedButton().name() != mainTabName) {
        UIATarget.localTarget().frontMostApp().tabBar().buttons()[mainTabName].tap();
    }

    // go back to the home
    UIALogger.logMessage("Go back to home.");
    var backButton = UIATarget.localTarget().frontMostApp().mainWindow().buttons()["Back"];
    if (backButton.isValid()) {
        backButton.tap();
    } else {
        UIALogger.logError("Could not find 'Back' button!");
    }
}
Run Code Online (Sandbox Code Playgroud)

现在,我无法通过错误"无法找到'返回'按钮!".它在那里,在左角,盯着我,嘲弄我!

UIATarget.localTarget().frontMostApp().logElementTree()给了我下面的树:

2) UIAApplication [name:MyApplication value:(null) rect:{{x:0, y:20}, {width:320, height:460}}]
3) UIAWindow [name:(null) value:(null) rect:{{x:0, y:0}, {width:320, height:480}}]
4) UIAImage [name:(null) value:(null) …
Run Code Online (Sandbox Code Playgroud)

iphone xcode cocoa-touch instruments ios-ui-automation

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

打印纸张尺寸和内容插入

我正在使用以下代码来打印包含文本和图像的HTML内容.

if (![UIPrintInteractionController isPrintingAvailable]) {
    UIAlertView *alertView = [[[UIAlertView alloc] 
        initWithTitle:NSLocalizedString(@"Printer Availability Error Title", @"")
        message:NSLocalizedString(@"Printer Availability Error Message", @"")
        delegate:nil
        cancelButtonTitle:NSLocalizedString(@"OK", @"OK")
        otherButtonTitles:nil] autorelease];
    [alertView show];
    return;
}

UIPrintInteractionController *pic = 
    [UIPrintInteractionController sharedPrintController];

if(!pic) {
    NSLog(@"Couldn't get shared UIPrintInteractionController!");
    return;
}

pic.delegate = self;

UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = @"Sample";
pic.printInfo = printInfo;

NSString *htmlString = [self prepareHTMLText];
UIMarkupTextPrintFormatter *htmlFormatter = 
    [[UIMarkupTextPrintFormatter alloc] initWithMarkupText:htmlString];
htmlFormatter.startPage = 0;
// 1-inch margins on all sides
htmlFormatter.contentInsets …
Run Code Online (Sandbox Code Playgroud)

html printing ios airprint uiprintinteractioncntrler

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

在我的iOS应用程序中使用条形码扫描仪(如Grabba)

我的目标很简单:从条形码扫描仪读取数据.

我知道有一个使用相机扫描条形码的选项,但根据我的经验,在不太理想的情况下结果不是很准确,即光线不好.所以,我正在探索外部设备是否可以轻松地与iPhone/iPad连接,并且可以像外部键盘一样提供条形码数据.

那么,我可以读取使用外部设备扫描的条形码吗?如果是这样,我可以在不编写任何代码的情况下完成,或者我是否必须在我的应用程序中专门添加某种支持?

barcode barcode-scanner ios

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

无法下载应用程序 + 应用程序不再可用

我们有一个使用企业分发配置文件分发的应用程序。现在,同一个应用程序对某些人有效,但其他人报告了以下问题。

  • 现有/已安装的应用程序会引发此错误,并且无法打开:

    {应用程序名称}不再可用

  • 尝试从 Enterprise 链接下载应用程序的用户报告此错误:

    无法下载应用程序 - 此时无法安装 {App Name}。

    Done Retry

运行 iOS 8.4.1 的用户专门报告了这些问题。我重新生成了配置文件并重建了应用程序。这似乎解决了部分用户的问题,但并没有解决所有用户的问题。

这里真正的问题是什么?想法?

deployment enterprise ios ios-provisioning

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