小编Wri*_*sCS的帖子

修剪文件扩展名UITableView

我想从NSMutableArray表格单元格中的文本修剪文件扩展名.

NSMutableArray *theFiles = [NSMutableArray new];
NSFileManager *manager = [NSFileManager defaultManager];
NSArray *fileList = [manager directoryContentsAtPath:@"/Test"];
for (NSString *s in fileList){
    [theFiles addObject:fileList];
}
cell.textLabel.text = theFiles[indexPath.row];
return cell;
Run Code Online (Sandbox Code Playgroud)

这列出例如"Xylophone.m4r"我想删除.m4r.

trim nsstring nsmutablearray

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

iPhone Wi-Fi Manager SDK

我正在尝试几种尝试启用/禁用Wi-Fi(切换)的方法.以下是我正在尝试的一些事情:

//Enable
WiFiManagerClientEnable(WiFiManagerClientCreate(kCFAllocatorDefault, 0));
//Disable
WiFiManagerClientDisable(WiFiManagerClientCreate(kCFAllocatorDefault, 0));
Run Code Online (Sandbox Code Playgroud)

-和-

//Enable
WiFiManagerClientSetProperty(WiFiManagerClientCreate(kCFAllocatorDefault, 0), @"AllowEnable", kCFBooleanTrue);
//Disable
WiFiManagerClientSetProperty(WiFiManagerClientCreate(kCFAllocatorDefault, 0), @"AllowEnable", kCFBooleanFalse);
Run Code Online (Sandbox Code Playgroud)

即使我有一个异常函数(@try {}),每个最终都会崩溃应用程序.我已经导入了MobileWiFi.framework和所有东西,但似乎无法让它工作.这些是我需要调用的正确方法才能启用/禁用Wi-Fi吗?

注意:不适用于APP STORE :-)

iphone sdk toggle wifi

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

在Xcode中调试时自动打开终端?

在Xcode中调试可执行文件时,我经常需要打开一个终端窗口,导航到可执行文件的工作目录并在那里做一些工作.有没有什么办法让我每次调试程序时Xcode都会在这个位置自动打开一个终端窗口?

macos terminal xcode automation

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

iPhone上的Twitter OAuth登录页面

在Sharekit的帮助下,我将Twitter集成到我的应用程序中.一切都运行良好,除非用户碰巧点击登录/允许页面上的"注册"链接,它会转到非注册错误页面.要么"抱歉该页面不存在"或"举起!抱歉,您尝试查看的个人资料因异常活动而被暂停."

我正在使用的帐户正在登录,发布等工作.但该链接似乎进入太空.此外,如果我点击"Twitter Gear"/应用程序图标,则会关闭对话框(加载了Twitter OAuth授权页面的Web视图).

我找不到任何关于如何配置这样的东西的东西,其他一切看起来很容易.我能找到的最接近的参考是,这个链接Twitter API Issue 1045

在此先感谢任何帮助

更新:我一直在检查其他几个支持Twitter的应用程序.我检查的大多数(TUAW,Joystiq,TFLN)似乎已经推出了他们自己的Twitter登录页面(使用XAuth我假设)我发现使用Twitter OAuth页面(Shazam)实际上将您带到移动Safari和它表现出相同的行为.也许我需要滚动自己的登录?

iphone twitter ios sharekit twitter-oauth

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

iPhone - 读取Setting.bundle返回错误的值

我创建了一个随Root.plist文件和本地化目录en.lproj一起提供的Settings.bundle.

我编辑了Root.plist并添加了几个我想要的应用程序设置.

当我从iPhone删除应用程序并安装它并第一次运行时,我读取的所有设置都返回错误的值.例如:

highQualityFlag = [[[NSUserDefaults standardUserDefaults] stringForKey:@"qualityFlag"] boolValue];
Run Code Online (Sandbox Code Playgroud)

即使设置默认值为YES,该标志也为NO.

如果我在设置上更改了某些内容并再次运行,则所有后续运行都会给出正确的值(??)

我该如何解决?

谢谢

iphone settings.bundle

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

关于如何将UIView作为UITableViewCell选择后备视图的明确答案

我已经阅读并尝试了一些我在StackOverflow上找到的答案.我也从博客中读过并试过一些东西,但似乎没有什么能达到我想要的效果.

我创建了一个UIView并将其背景颜色设置为我想要的UITableViewCell选择颜色(而不是标准的蓝色或灰色选择颜色).我将它添加UIView到我的单元格中selectedBackgroundView,这很好用,我的单元格在用户选择时更改为所需的颜色.

这种方法在Plain上很有效UITableViews; 在Grouped上不太好.在分组上UITableView,第1个和最后一个单元格不符合剪辑/蒙版界限,如下面的屏幕截图所示.

我知道没有办法只围绕左上角和右上角.

我想严格按代码执行此操作,无需图像.

有没有人知道一个很好的小工作来改变selectedBackgroundView一个UITableViewCell只使用UIView而不是图像的颜色和使第一个和最后一个单元格符合圆角边界?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * CellIdentifier = @"Cell";
    WCSBadgedCell   * cell = [[WCSBadgedCell alloc] initWithStyle:UITableViewCellStyleSubtitle andBadgeStyle:0 reuseIdentifier:CellIdentifier]; 
    if (cell == nil) {
        cell = [[WCSBadgedCell alloc] initWithStyle:UITableViewCellStyleDefault andBadgeStyle:0 reuseIdentifier:CellIdentifier];
    }

    UIView *bgColorView = [[UIView alloc] init];
    [bgColorView setBackgroundColor:DARKBROWN];
    [bgColorView setClipsToBounds: YES];
    [cell.layer setMasksToBounds:YES];
    [cell setSelectedBackgroundView:bgColorView];

    [cell.textLabel …
Run Code Online (Sandbox Code Playgroud)

uitableview uiview ios

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

该行动无法完成.(可可错误:3840.)

我试图解析一个ios 6应用程序的JSON,但似乎无法让它工作.我已经搜索了大量的论坛,但没有找到一个有效的解决方案,我理解足以实现,或者适用.

如果有一个我错过了,我道歉.

首先,我有一个测试WebService,据我所知,返回有效的JSON

http://thetrouthunter.com/SVLocationsAPI.php

其次,这是我的Objective-C代码:

+ (NSDictionary *)connectToService:(NSString *)query
{
    NSError *error = nil;

    query = [NSString stringWithFormat:@"%@&format=json&nojsoncallback=1", query];
    query = [query stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    NSData *jsonData = [[NSString stringWithContentsOfURL:[NSURL URLWithString:query] encoding:NSUTF8StringEncoding error:nil] dataUsingEncoding:NSUTF8StringEncoding];

    NSDictionary *results = jsonData ? [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers|NSJSONReadingMutableLeaves error:&error] : nil;

    NSLog(@"locations: %@", results);

    if (error)
        NSLog(@"[%@ %@] JSON error: %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), error.localizedDescription);

    return results;
}

+ (NSArray *)userLocation {
    NSString *request = [NSString stringWithFormat:@"http://thetrouthunter.com/SVLocationsAPI.php"];
    return [[self connectToService:request] valueForKeyPath:@"locations.location"];
}
Run Code Online (Sandbox Code Playgroud)

ls NSLog函数打印出错误:"操作无法完成.(可可错误:3840.)"

我无法弄清楚为什么会这样.我尝试过各种各样的事情.

json web-services objective-c nsjsonserialization ios6

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

如何动态放大UILabel(标签和字体大小)?

我目前正在开发一个iPhone项目.我想在Objective-C中动态扩展UILabel,如下所示:

替代文字http://img268.imageshack.us/img268/9683/bildschirmfoto20100323u.png

这怎么可能?我认为我必须使用CoreAnimation,但我没有工作.这是我试过的代码:

UILabel * fooL = //[…]
fooL.frame = CGRectMake(fooL.frame.origin.x, fooL.frame.origin.y, fooL.frame.size.width, fooL.frame.size.height);   
fooL.font = [UIFont fontWithName:@"Helvetica" size:80];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[UIView setAnimationBeginsFromCurrentState:YES];
fooL.font = [UIFont fontWithName:@"Helvetica" size:144]; //bigger size
fooL.frame = CGRectMake(20 , 44, 728, 167); //bigger frame
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)

此代码的问题在于它不会动态更改fontsize.

core-animation objective-c uilabel

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

如何创建iPad文档预览界面,如iWorks for iPad中的界面

愿意为一个有效的例子奖励+500赏金.

我知道只有2个源代码示例可以在iPad上完成文档预览界面,就像在Number,Pages等中找到的那样.

infoNgenOmniGroup框架

还有其他例子吗?infoNgen这是一个很好的简单例子,然而,代码非常草率,写得非常糟糕,非常无组织.

OmniGroup 是一个很棒的库,但对于简单的项目来说太复杂了.

替代文字

更新

我能够分解infoNgen的项目,并使用HTML预览创建一个准系统文档查看器,这似乎与更新文档中的信息并保持与预览同步非常有效.现在要解决的问题是,当应用程序退出并重新启动时,文档会保存.+500赏金仍然可用于一个工作示例,但是,除非发布了工作示例,否则我不会打开赏金.

user-interface ipad ios document-preview document-carousel

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

如何增加重复本地通知的应用程序徽章编号(iPhone)

我已经设置了每分钟重复的本地通知,但是我需要每次都增加应用程序徽章编号.当我运行它的时候它似乎没有增加,它只是保持1.请有人帮助我吗?

以下是我创建通知的方法:

// Create the UILocalNotification
UILocalNotification *myNotification = [[UILocalNotification alloc] init];
myNotification.alertBody = @"Blah blah blah...";
myNotification.alertAction = @"Blah";
myNotification.soundName = UILocalNotificationDefaultSoundName;
myNotification.applicationIconBadgeNumber++;
myNotification.timeZone = [NSTimeZone defaultTimeZone];
myNotification.repeatInterval = NSMinuteCalendarUnit;
myNotification.fireDate = [[NSDate date] dateByAddingTimeInterval:30];
[[UIApplication sharedApplication] scheduleLocalNotification:myNotification];
Run Code Online (Sandbox Code Playgroud)

iphone uilocalnotification

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