我正在尝试使用UIDocumentInteractionController预览文档.该文档是我的应用程序从网上下载的.xls文件.我一直收到这个错误:
'UIDocumentInteractionController: invalid scheme (null). Only the file scheme is supported.'
Run Code Online (Sandbox Code Playgroud)
我用下一个代码:
- (void) webServiceController:(WebServiceController *)webServiceController returnedArray:(NSMutableArray *)array {
if ([webServiceController.webRequest isEqualToString: @"generateExcelFileForEmployee"]) {
// start previewing the document at the current section index
NSString *link = [[NSString stringWithString:array[0]] stringByReplacingOccurrencesOfString:@"AdminFunctions.php" withString:@"AdminFunctions.xls"];
link = [[[link stringByReplacingOccurrencesOfString:@"\\" withString:@""]stringByReplacingOccurrencesOfString:@"/public/sites/" withString:@"http://"]stringByReplacingOccurrencesOfString:@"\"\\\"" withString:@""];
NSLog(@"%@", link);
NSData *urlData = [NSData dataWithContentsOfURL:[NSURL URLWithString:link]];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,@"AdminFunctions.xls"];
BOOL isWriteSuccess = [urlData writeToFile:filePath atomically:YES];
NSLog(@"%@", …Run Code Online (Sandbox Code Playgroud) 如果开发人员没有需要或使用Xcode 7进行代码签名,那么如何使用xcode 7 realease实现.
因为它仍然显示错误: CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 9.0'
有可能吗?
解决方案:它没有US male voice
我已经习惯AVSpeechSynthesizer framework了iOS7.0
AVSpeechUtterance *utt = [AVSpeechUtterance speechUtteranceWithString:@"Hello"];
if (isMale) //flag for male or female voice selected
{
// need US male voice as en-US is providing only US female voice
utt.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-GB"]; //UK male voice
}
else
{
utt.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"]; //US female voice
}
Run Code Online (Sandbox Code Playgroud)
我需要用US male voice而不是male UK voice.
在开发过程中universal apps,我们必须conditional code为每个人写一个device- iPad以及iPhone.在这种情况下,正确使用tilde可能是非常有益的.
例如,如果你想推送新的视图控制器,那么你必须编写很多代码行(差不多10行):
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:@”MasterViewController_iphone” bundle:nil];
[self.navigationController pushViewController:masterViewController animated:YES];
[masterViewController release];
}
else
{
MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:@”MasterViewController_ipad” bundle:nil];
[self.navigationController pushViewController:masterViewController animated:YES];
[masterViewController release];
}
Run Code Online (Sandbox Code Playgroud)
我们如何区分iphone和ipad的图像?
我能够使用NSMutableURLRequest与NSURLConnection连接到SOAP Web服务,具体如下:
NSString *soapMessage = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
"<soap:Body>"
"<CelsiusToFahrenheit xmlns=\"http://www.w3schools.com/webservices/\">"
"<Celsius>140.0</Celsius>"
"</CelsiusToFahrenheit>"
"</soap:Body>"
"</soap:Envelope>"];
NSData *soapData = [soapMessage dataUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:@"http://w3schools.com/webservices/tempconvert.asmx"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%lu", (unsigned long)[soapMessage length]];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"http://www.w3schools.com/webservices/CelsiusToFahrenheit" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue:@"www.w3schools.com" forHTTPHeaderField:@"Host"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:soapData];
Run Code Online (Sandbox Code Playgroud)
我怎么能使用AFNetworking或STHTTPRequest做同样的事情?
I have done below code so far for UIView's viewPrintFormatter to be able create PDF:
Category of UIPrintPageRenderer for getting PDF Data@interface UIPrintPageRenderer (PDF)
- (NSData*) printToPDF;
@end
@implementation UIPrintPageRenderer (PDF)
- (NSData*) printToPDF
{
NSMutableData *pdfData = [NSMutableData data];
UIGraphicsBeginPDFContextToData( pdfData, self.paperRect, nil );
[self prepareForDrawingPages: …Run Code Online (Sandbox Code Playgroud) 我正在开发一个iPhone应用程序,我使用HTML来显示格式化的文本.
我经常显示相同的网页,但内容不同.我想使用模板HTML文件,然后用我的不同值填充它.
我想知道Objective-C是否有类似于Ruby中的ERB的模板系统.
这样就可以做到这样的事情
模板:
<HTML>
<HEAD>
</HEAD>
<BODY>
<H1>{{{title}}}</H1>
<P>{{{content}}}</P>
</BODY>
</HTML>
Run Code Online (Sandbox Code Playgroud)
Objective-C(或者它可能在理想世界中)
Template* template = [[Template alloc] initWithFile:@"my_template.tpl"];
[template fillMarker:@"title" withContent:@"My Title"];
[template fillMarker:@"content" withContent:@"My text here"];
[template process];
NSString* result = [template result];
[template release];
Run Code Online (Sandbox Code Playgroud)
结果字符串将包含:
<HTML>
<HEAD>
</HEAD>
<BODY>
<H1>My Title</H1>
<P>My text here</P>
</BODY>
</HTML>
Run Code Online (Sandbox Code Playgroud)
上面的例子可以通过一些文本替换来实现,但这将是一个难以维护.我还需要像模板中的循环一样的东西.例如,如果我要显示多个项目,我想生成多个div.
谢谢阅读 :)
增加了KVO对AVPlayer当播放视频queuePlayer是AVPlayer
[self.queuePlayer addObserver:self forKeyPath:@"status" options:0 context:NULL];
Run Code Online (Sandbox Code Playgroud)
observer method:
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if ([keyPath isEqualToString:@"status"]) {
if (self.queuePlayer.status == AVPlayerStatusReadyToPlay) {
NSInteger step = (NSInteger)(startTimeForVideo/0.04);
[self.queuePlayer.currentItem stepByCount:step];
//CMTime seekTime = CMTimeMake(startTimeForVideo*timeScale,timeScale);
//if (CMTIME_IS_VALID(seekTime))
// [self.queuePlayer seekToTime:seekTime toleranceBefore:kCMTimePositiveInfinity toleranceAfter:kCMTimePositiveInfinity];
//else
// NSLog(@"In valid time");
[self.queuePlayer play];
} else if (self.queuePlayer.status == AVPlayerStatusFailed) {
/* An error was encountered */
}
}
Run Code Online (Sandbox Code Playgroud)
这里startTimeForVideo初始playBack time为video
seekToTime …
随着NSArray只有我能找到值:
NSArray *arr = [NSArray arrayWithObjects:@"299-1-1", @"299-2-1", @"299-3-1", @"399-1-1", @"399-2-1", @"399-3-1", @"499-1-1", @"499-2-1", @"499-3-1", nil];
NSString *search = @"299";
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF CONTAINS %@",[NSString stringWithFormat:@"%@", search]];
NSArray *array = [arr filteredArrayUsingPredicate: predicate];
NSLog(@"result: %@", array);
Run Code Online (Sandbox Code Playgroud)
Found Result 正如所料:
result: (
"299-1-1",
"299-2-1",
"299-3-1"
)
Run Code Online (Sandbox Code Playgroud)
但对于NSArray其NSArray与NSString
NSArray *arr = [NSArray arrayWithObjects:[NSArray arrayWithObjects:@"299-1-1", nil],[NSArray arrayWithObjects:@"399-1-1", nil],[NSArray arrayWithObjects:@"499-1-1", nil], nil];
Run Code Online (Sandbox Code Playgroud)
会在predicate syntax这里?????
我们可以通过UIStackView最初的垂直轴然后最终它将是水平轴来实现这一点,反之亦然吗?
如果使用NSAutoLayout,如何做到这一点?
如果有人可以为我提供示例来源或此处的任何提示都会有所帮助,则需要帮助。

下图为橙色区域,放置婴儿手掌.所有我需要知道如何检测婴儿plam是正确还是左.

ios ×10
objective-c ×9
iphone ×7
xcode ×2
afnetworking ×1
avplayer ×1
excel ×1
file ×1
ios7 ×1
multi-touch ×1
nsdata ×1
nspredicate ×1
preview ×1
swift ×1
templates ×1
uistackview ×1
uitouch ×1