我已经看到Apple的示例"TableSearch"触摸其范围按钮时会出现在搜索栏下方. http://developer.apple.com/iphone/library/samplecode/TableSearch/Introduction/Intro.html
但是当我自己制作时它看起来很不错但是当我触摸它看起来像丑陋时,范围按钮和搜索栏显示在同一行如下:http: //cl.ly/BN9
我该怎么办才能让它像iPad中的"TableSearch"一样?
我正在做IB中的所有事情,并尝试从控制器以编程方式修改搜索栏:
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.rowHeight = 88.0f;
self.tableView.contentOffset = CGPointMake(0, self.searchDisplayController.searchBar.frame.size.height);
self.searchDisplayController.searchResultsTableView.rowHeight = self.tableView.rowHeight;
//BELOW DID NOT WORK:
CGRect b = self.searchDisplayController.searchBar.bounds;
self.searchDisplayController.searchBar.bounds = CGRectMake(b.origin.x, b.origin.y, b.size.width, self.tableView.rowHeight);
b = self.searchDisplayController.searchBar.frame;
self.searchDisplayController.searchBar.frame = CGRectMake(b.origin.x, b.origin.y, b.size.width, self.tableView.rowHeight);
//BELOW WORKS PERFECT BUT IS A PRIVATE METHOD, HENCE I AM NOT SUPPOSED TO USE IT
//[self.searchDisplayController.searchBar setCombinesLandscapeBars:NO];
}
Run Code Online (Sandbox Code Playgroud)
提前致谢.
我正在启动WebOS dev,我怀疑我应该从哪里开始并停止我的听众?我正在读这本书,但我找不到明确的解释.在示例中,作者在设置函数中设置了侦听器,但我想知道为什么?在模板的注释建议中,将它们设置为激活功能并将其停止在停用功能中是不是更好的主意?
万一我错了什么样的事件应该和不应该放在设置和激活功能?
何时完全设置,激活,取消激活,清除功能?
StoryViewAssistant.prototype.setup = function() {
//HERE, OK?
this.nextStoryHandler = this.nextStory.bindAsEventListener(this);
this.previousStoryHandler = this.previousStory.bindAsEventListener(this);
this.controller.listen("nextStory", Mojo.Event.tap, this.nextStoryHandler);
this.controller.listen("previousStory", Mojo.Event.tap,this.previousStoryHandler);
/* add event handlers to listen to events from widgets */
};
StoryViewAssistant.prototype.activate = function(event) {
//HERE?
/* put in event handlers here that should only be in effect when this scene is active. For example, key handlers that are observing the document */
};
StoryViewAssistant.prototype.deactivate = function(event) {
//HERE?
/* remove any event handlers …
Run Code Online (Sandbox Code Playgroud) 我正在玩AppKit和NSDocument,我不知道为什么这不起作用?:
我刚刚写了这个,图像不是零,但从不加载任何图像,它的大小始终为零.这是我必须实现的将文件读入我的文档的正确方法吗?我需要路径,而不是数据(NSData),因为我打算使用其他库来读取其他文件.
现在我正在尝试阅读PNG,JPG,没有工作.(
- (BOOL) readFromURL:(NSURL *)url ofType:(NSString *)typeName error:(NSError **)outError{
NSImage *image = nil;
image = [[NSImage alloc] initWithContentsOfURL:url];
[imageView setImage:image];
[image release];
if ( outError != NULL ) {
*outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:unimpErr userInfo:NULL];
}
return YES;
}
Run Code Online (Sandbox Code Playgroud)
提前致谢.
我有一个可缩放的UIScrollView,里面有一些CATextLayer
s和简单的CALayer
s.它们被渲染得很好,但问题是当它们被缩放时它们会变得模糊.(即使我重绘它们)
当缩放视图时,我的选择是什么让我的文字不模糊?我应该用另一件东西吗?启用CATextLayer
/中的某些内容CALayer
?欢迎任何想法;)
我正在使用CALayer
s,因为正如文档中所建议的,CALayer
s比UIViews
我更轻,而且我有数百个.目前它运作顺利.我试过了UIWebView
,我的CALayer
版本更快;)
提前致谢.
我刚写了这段代码来表示这个错误就是杀了我(Grrr!)
我想知道为什么当我得到错误:方法未定义我已经检查了Safari并且这个变量在parserDidStart()方法中不是EpisodeController类型它是EpisodeFeedParser类型为什么这个?
<html>
<head>
<script type="text/javascript">
var EpisodeFeedParser = function(url){
this.url = url;
this.didStartCallback = null;
};
EpisodeFeedParser.prototype.parse = function(doc){
this.didStartCallback(this);
};
var EpisodeController = function(){
this.episodes = new Array();
this.parser = null; //lazy
};
EpisodeController.prototype.parserDidStart = function(parser){
console.log("here *this* is not of type EpisodeController but it is EpisodeFeedParser Why?");
this.testEpi(); //**********ERROR HERE!***********
};
EpisodeController.prototype.fetchEpisodes = function(urlString){
if(urlString !== undefined){
if(parser === undefined){
var parser = new EpisodeFeedParser(urlString);
parser.didStartCallback = this.parserDidStart;
this.parser = parser;
}
this.parser.parse();
}
}; …
Run Code Online (Sandbox Code Playgroud) 我想得到一个目录中的文件列表,但我需要知道该文件是否是一个目录,上次修改时,以及其名称:).所以我尝试了这个:
NSFileManager *fm = [NSFileManager defaultManager];
NSURL *directoryURL = [NSURL fileURLWithPath:@"/Users/nacho4d/Desktop/"];
NSArray *urls = [fm contentsOfDirectoryAtURL:directoryURL
includingPropertiesForKeys:[NSArray arrayWithObjects:NSURLNameKey, NSURLIsDirectoryKey, NSURLContentModificationDateKey, nil]
options:NSDirectoryEnumerationSkipsHiddenFiles
error:nil];
NSError *error = nil;
NSString *name;
NSDate *modificationDate;
NSNumber *isDirectory;
for (NSURL *url in urls) {
if (![url getResourceValue:&name forKey:NSURLNameKey error:&error]) {
NSLog(@"name: %@", [error localizedDescription]);error = nil;
}
if (![url getResourceValue:&modificationDate forKey:NSURLContentModificationDateKey error:&error]) {
NSLog(@"modificationDate: %@", [error localizedDescription]); error = nil;
}
if (![url getResourceValue:&isDirectory forKey:NSURLIsDirectoryKey error:&error]) {
NSLog(@"isDirectory: %@", [error localizedDescription]); error = nil;
} …
Run Code Online (Sandbox Code Playgroud) 我在基于文档的应用程序中启用了版本和自动保存,所以现在我可以在OSX 10.7中看到每个文档的版本浏览器(类似时间机器的界面)
+ (BOOL)autosavesInPlace{ return YES; }
Run Code Online (Sandbox Code Playgroud)
我有一个textview,并且在WWDC视频的一个会话107中建议,我想在进入版本浏览器时禁用文本输入等.所以我实现了NSWindowDelegate方法:
- (void)windowWillEnterVersionBrowser:(NSNotification *)notification{
[myTextView setEditable:NO];
}
- (void)windowWillExitVersionBrowser:(NSNotification *)notification{
[myTextView setEditable:YES];
}
Run Code Online (Sandbox Code Playgroud)
现在,myTextView
在屏幕左侧的文档(当前文档)窗口中被禁用,但右侧的文档(过去的版本)仍然显示光标.
textView不可编辑,但光标显示.我也禁用其他东西并在上面的方法中重新启用它们,但是在上面的方法中编写代码似乎只影响当前的文档窗口/文档而不是过去的版本windows/document.
也许其他人有同样的问题?我怎样才能正常工作?:)
编辑:
我正在寻找会话107的WWDC示例代码,但文件夹是空的.我错过了什么或者没有这个会话的示例代码吗?
编辑2:
应用程序工具包发行说明(Lion)说windowForSheet
在创建版本浏览器右侧的窗口时调用:
- (NSWindow *)windowForSheet{
CustomWindow *win = (CustomWindow *)[super windowForSheet];
[win setUserInteractionEnabled:![self isInViewingMode]]; //disable stuff here
return win;
}
Run Code Online (Sandbox Code Playgroud)
但是现在当窗口从版本浏览器返回时,用户交互仍然被禁用.:(
我想以编程方式设置标记文本,因为iOS5 UITextView和UITextField符合UITextInput,这应该是可能的,但由于某种原因,我总是得到markedText
为零.:(我在这里失踪了什么?
这是我试过没有成功的:
(虽然textview是firstResponder)
1.-当文本视图不包含文本时:
text:"",selectedRange:{0,0},markedText:nil.
[_textView setMarkedText:@"?" selectedRange:NSMakeRange(0, 1)];
Run Code Online (Sandbox Code Playgroud)
结果: text:"",selectedRange:{0,0},markedText:nil.(没有改变)
2.-当文本视图包含文本+一些标记文本时:
文字:"AAA",selectedRange = {0,3},最后标记文字:"太阳"然后我做:
[_textView setMarkedText:@"?" selectedRange:NSMakeRange(0,3)];
Run Code Online (Sandbox Code Playgroud)
结果: text:"AAA",selectedRange:{0,3},markedText:nil; (标记的文字为零)
在这两种情况下,就像setMarkedText:selectedRange:
将当前标记的文本(如果有的话)设置为nil一样.
任何帮助将非常感谢:)
由于标记文本的概念似乎不清楚,这里有一个解释:
在多阶段输入语言(例如日语)中,您可以输入常规文本(如英语)或输入标记文本(如日语).
在这里我写了常规文本:regular text
然后我写了标记文本?
然后我写了标记文本,?
所以它被附加成为??
.
标记文本(蓝色框中的文本)表示过渡或中间输入阶段,因为它可以变成其他称为候选者的字符/单词.候选人出现在大盒子里.
此屏幕截图是在iPad中使用蓝牙键盘时拍摄的,但在编写日语时使用软件键盘时会得到类似的结果.
在编写?
textview 之前是:
textView.text : "regular text"
textView.selectedRange : {12,0}
textView.markedText:nil
Run Code Online (Sandbox Code Playgroud)
然后我写?
了,文本视图变成了:
textView.text : "regular text?"
textView.selectedRange : {13,0}
textView.markedText: "?"
Run Code Online (Sandbox Code Playgroud)
然后我写?
了,文本视图变成了:
textView.text : "regular text??"
textView.selectedRange : {14,0}
textView.markedText: "??"
Run Code Online (Sandbox Code Playgroud)
这是文本视图的当前状态. …
我想在我的应用程序中编写一个不那么复杂但很大的文件,并且能够通过邮件发送它(使用MFMailComposeViewController)因为NSXMLElement和相关的类没有移植到iPhone SDK,我有什么选择来创建XML文档?提前致谢.
我正在尝试在Obj-c运行时引用中找到此方法
BOOL class_addMethod(Class cls, SEL name, IMP imp, const char *types)
Run Code Online (Sandbox Code Playgroud)
我想添加一个新的方法,如:
- [AClass drawWithFrame:(NSRect)rect inView:(id)view]
Run Code Online (Sandbox Code Playgroud)
到目前为止,我已经编写了一个C函数:
void drawWithFrameInView(id this, SEL this_cmd, NSRect frame, id view){
...
}
Run Code Online (Sandbox Code Playgroud)
现在我准备做了:
BOOL success = class_addMethod(NSClassFromString(@"AClass"),
@selector(drawWithFrame:inView:),
(IMP)drawWithFrameInView,
"v@:@:@:");
Run Code Online (Sandbox Code Playgroud)
但是success
从来没有,我尝试了同样的方法,使用更简单的签名方法,并且它有效.所以我认为问题是最后一个参数:"v@:@:@:"
在这种情况下我应该通过什么才能使我的新方法有效?
iphone ×4
objective-c ×4
cocoa ×3
cocoa-touch ×2
calayer ×1
ipad ×1
javascript ×1
macos ×1
mojo ×1
nsdocument ×1
nsimage ×1
osx-lion ×1
palm-pre ×1
palm-pre2 ×1
prototype ×1
scope ×1
this ×1
uiscrollview ×1
uisearchbar ×1
uitextinput ×1
uitextview ×1
webos ×1
xml ×1
xmlwriter ×1