小编Dha*_*iya的帖子

NSURLConnection优化

我试图NSURLConnection通过iPhone 了解3G网络的性能.我有以下测试代码

-(void)doTest2 {
     max = 5;
     NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
     NSURLRequest *request2 = [[[NSURLRequest alloc] initWithURL:url] autorelease];  
     NSURLConnection *conn=[[NSURLConnection alloc] initWithRequest:request2 delegate:self];  
     self.startDate = [NSDate date];
     if (conn)   
     {  
        receivedData = [[NSMutableData data] retain];  
     }  }   

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {  
       self.endDate = [NSDate date];
       NSTimeInterval interval = [self.endDate      timeIntervalSinceDate:self.startDate];
       NSLog(@"Time:%f Size:%u", interval, [receivedData length]);
      [receivedData release];  

       count = count + 1;
       if (count == max) { 
          count = 0;
          sleep(3);
       }
       self.doTest2;}
Run Code Online (Sandbox Code Playgroud)

第一个请求很慢(超过1秒).请求2-5很快(低于0.25秒).如果我睡了3秒或更长时间,睡眠后的第一个请求很慢.但如果我睡了不到3秒钟,那就快了.有什么想法吗?

objective-c nsurlconnection ios

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

iOS:我可以覆盖UIScrollView的捏合/缩小行为吗?

我在a上绘制了一个图形UIView,它由a包含,UIScrollView以便用户可以水平滚动以查看整个图形.

现在我想在用户用两个手指插入时缩放图形,但是我不想在X和Y方向上以相同的速率放大视图,我想通过改变X比例来仅在X方向上放大,而不改变Y量表.

我想我必须抓住捏合进/出手势并重绘图形,覆盖默认的缩放行为.

但是有办法做到这一点吗?

我一直很难抓住捏手势UIScrollView,因为它在开始滚动时取消了触摸.我希望即使UIScrollView取消触摸后缩放也能正常工作.:(

谢谢,库拉

iphone uiscrollview ios

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

从iphone sdk中的uiwebview下载文件

有没有办法从UIWebView我在我的IBAction活动中使用此代码下载文件

- (IBAction)saveFile:(id)sender {
// Get the URL of the loaded ressource
NSURL *theRessourcesURL = [[self.webDisplay request] URL];
NSString *fileExtension = [theRessourcesURL pathExtension];

if ([fileExtension isEqualToString:@"png"] || [fileExtension isEqualToString:@"jpg"] || 
    [fileExtension isEqualToString:@"pdf"] || [fileExtension isEqualToString:@"html"]) {
    // Get the filename of the loaded ressource form the UIWebView's request URL
    NSString *filename = [theRessourcesURL lastPathComponent];
    NSLog(@"Filename: %@", filename);
    // Get the path to the App's Documents directory
    NSString *docPath = [self documentsDirectoryPath];
    // Combine the filename and …
Run Code Online (Sandbox Code Playgroud)

iphone uiwebview ios

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

iOS UIwebView Auth Cookies

我有一个UIWebView加载用户身份验证的网站.该站点创建一个身份验证cookie.在浏览器中,除非您清除cookie,否则您将始终登录.当xCODE加载时,它可以在查看cookie jar时看到列出的cookie,但不会发送到webView.我想知道如何让webView意识到auth cookie就在那里,所以它不会每次都继续提示用户进行身份验证.

iphone objective-c++ webview ipad ios

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

UITabBar - 使用Storyboard的两个视图(笔尖)相同的类

我正在使用iOS 5和Storyboard.我UITabBar是使用Interface Builder创建的.我的两个相似的项目TabBar是相同的列表,只是其中包含不同类型的项目.我所做的,但看起来很奇怪,是为每个UITableView和在中设置一个不同的"标签" viewDidLoad,然后根据标签分配正确的类型.

- (void)viewDidLoad
{
    [super viewDidLoad];

    if (self.tableView.tag == 1)
    {
        type = @"lent";
    }
    else if (self.tableView.tag == 2)
    {
        type = @"borrowed";
    }
}
Run Code Online (Sandbox Code Playgroud)

有更好的方法吗?我没有创建我UITabBar的代码,所以我AppDelegate很空!我设置的类型只是我的一个核心数据实体中的一个属性,在列表中我有借用项目,另一个我有借用项目,但它们是同一个实体.

iphone objective-c ios

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

IPConfiguration apple80211Open() 在 iOS8 上崩溃

我正在尝试读取 iPhone WIFI 连接到 AP 的 RSSI。

在 iPhone6+ ios 8.1.3 上使用 Xcode 6.1.1

下面的代码在 iOS 8 上崩溃apple80211Open()并获得 E。XC_BAD_ACCESS (code=1, address= 0)(代码适用于 iOS 7.1)

这适用于不适用于 Apple Store 的应用程序——仅适用于临时分发。

================================================== ================

void *libHandle;
   void *airportHandle;

   int (*apple80211Open)(void *);
   int (*apple80211Bind)(void *, NSString *);
   int (*apple80211Close)(void *);
   int (*apple80211GetInfoCopy)(void *, CFDictionaryRef *);

   NSMutableDictionary *infoDict = [NSMutableDictionary new];
   NSDictionary * tempDictionary;
   libHandle = dlopen("/System/Library/SystemConfiguration/IPConfiguration.bundle/IPConfiguration", RTLD_LAZY);

   char *dlerror_error;

   if (libHandle == NULL && (dlerror_error = dlerror()) != NULL)  {
      NSLog(@"%s", …
Run Code Online (Sandbox Code Playgroud)

iphone network-programming objective-c ios

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

如何更改 STATIC UITableView 中 UITableViewSection 的页脚?

您知道如何在 iOS 的“设置”应用程序中,您可以从多个设置中选择一个设置,并且设置单元格所在的UITableView页脚将会发生变化。UITableViewSection就像当您访问应用程序的“允许位置访问”设置时一样,当您在“从不”、“使用应用程序时”或“始终”之间切换时,设置下方的文本会发生变化。在我的应用程序中,我想实现类似的功能。我尝试过 reloadSection: ,并且我已经实现了tableView:titleForFooterInSection:,但是当我调用reloadSection:它时,它完全隐藏了我的UITableViewSection。那么如何访问 a UITableViewSectionof a的页脚static UITableView并更改它而不隐藏整个内容呢?谢谢。

objective-c uitableview ios swift

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

如何将图片加载到UIImageView保持其原始比例?

我想UIImageView从图书馆加载多张图片.

但是,图片的大小和比例UIImageView在加载时会改变大小

扭曲原始图片.

如何UIImageView在保持原始尺寸的同时加载图片?

uiimageview ios

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

索引NSFetchedResultsController

如何索引a NSFetchedResultsController以便我可以在tableview上实现AZ索引.

我在初始化程序中看到我能做到,sectionNameKeyPath但这只是在自己的部分中放置了唯一的对象.

这就是我对我的看法 NSFetchedResultsController

    - (NSFetchedResultsController *)fetchedResultsController
{
    if (__fetchedResultsController != nil) {
        return __fetchedResultsController;
    }

    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];

    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Customer" inManagedObjectContext:self.managedObjectContext];
    [fetchRequest setEntity:entity];

    [fetchRequest setFetchBatchSize:20];

    NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES];
    NSArray *sortDescriptors = [NSArray arrayWithObjects:sortDescriptor, nil];

    [fetchRequest setSortDescriptors:sortDescriptors];

    NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:@"name" cacheName:@"Customer"];
    aFetchedResultsController.delegate = self;

    self.fetchedResultsController = aFetchedResultsController;

    return __fetchedResultsController;
}  
Run Code Online (Sandbox Code Playgroud)

core-data uitableview nsfetchedresultscontroller ios

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

在UIImagePickerController中点击使用后保存视频

我有一个应用程序可以调用UIImagePickerController,并且您使用控制器拍摄视频.拍摄视频后,我希望在点击使用后将视频保存到相机胶卷中UIImagePickerController.

你能帮助我吗?

哦,并UIImagePickerController附带切换到视频,默认照片的选项.我希望这只是视频,而不是照片.

我目前的代码是:

picker.sourceType=UIImagePickerControllerCameraCaptureModeVideo;
picker.mediaTypes=[UIImagePickerController availableMediaTypesForSourceType:picker.sourceType];
Run Code Online (Sandbox Code Playgroud)

objective-c

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