有没有办法打开应用程序商店到特定的应用程序?我尝试使用以下内容:
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:@"http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=284417350&mt=8&uo=6"]];
Run Code Online (Sandbox Code Playgroud)
但得到以下内容:"Safari无法打开页面,因为发生了许多重定向".
我正在使用以下代码来创建UIRefreshControl:
- (void) viewDidLoad
{
[super viewDidLoad];
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self action:@selector(doLoad) forControlEvents:UIControlEventValueChanged];
self.refreshControl = refreshControl;
}
- (void) doLoad
{
dispatch_async(dispatch_get_global_queue(0, 0), ^{
// Instead of sleeping, I do a webrequest here.
[NSThread sleepForTimeInterval: 5];
dispatch_async(dispatch_get_main_queue(), ^{
[tableView reloadData];
[self.refreshControl endRefreshing];
});
});
}
Run Code Online (Sandbox Code Playgroud)
它很棒.如果我导航到我的视图,请拖动表格,代码运行并显示数据.
但是,我想要做的是在视图出现时将视图置于"加载"状态(这样用户知道某些事情正在发生).我尝试添加以下内容:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.refreshControl beginRefreshing];
}
Run Code Online (Sandbox Code Playgroud)
但它似乎没有用.当我导航到视图时,它看起来像一个常规视图(刷新控件不可见),当我尝试拉动刷新控件时,它从未完成加载.
显然我会以错误的方式解决这个问题.关于我应该如何处理的任何建议?
我在Objective-C中有一个协议,如下所示:
@protocol Handler
+(NSString*) getValue;
@end
Run Code Online (Sandbox Code Playgroud)
所以现在说我有一个继承这个协议的实例,我想调用这个方法:
[handlerInstance getValue];
Run Code Online (Sandbox Code Playgroud)
这会发出警告,因为该getValue方法不是实例方法.如何从我的实例中正确调用此方法?(不知道具体课程)?我猜是这样的,但我不确定:
[[handlerInstance class] getValue];
Run Code Online (Sandbox Code Playgroud) 我有以下代码:
public void Test(IMyInterface iInterface)
{
iInterface.CallMethod ( );
}
Run Code Online (Sandbox Code Playgroud)
哪个工作正常.但是,如果我将代码更改为线程:
private IMyInterface myInterface;
public void Test(IMyInterface iInterface)
{
myInterface = iInterface;
new Thread ( new ThreadStart ( CallInterfaceMethod) ).Start ( );
}
public void CallInterfaceMethod ( )
{
myInterface.CallMethod ( )
}
Run Code Online (Sandbox Code Playgroud)
当我使用线程时,我收到异常:
无法将"System .__ ComObject"类型的COM对象强制转换为接口类型"IMyInterface".此操作失败,因为对于具有IID"{GUID}"的接口的COM组件的QueryInterface调用由于以下错误而失败:不支持此类接口
但是应该支持接口就好了吗?有人对这里发生的事情有任何想法吗?
我正在尝试使用iTextSharp为文档添加表格.这是一个例子:
Document document = new Document(PageSize.LETTER,72, 72, 72, 72);
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("C:\\test.pdf", FileMode.Create));
document.Open();
Table table = new Table ( 2, 1 );
table.Width = document.RightMargin - document.LeftMargin;
// Cell placeholder
Cell cell = new Cell ( new Paragraph ( "Some Text" ) );
table.AddCell ( cell );
cell = new Cell ( new Paragraph ( "More Text" ) );
table.AddCell ( cell );
document.Add ( table );
document.Close ( );
Run Code Online (Sandbox Code Playgroud)
我正在设置表格的宽度,以便它应该扩展页面的边距.但是当创建pdf时,表格只占边距之间的80%.我在这里做错了吗?
我正在尝试添加自定义自动完成功能,我想在用户输入时触发(当然可配置).我找到了几个代码镜像自动完成的例子:
http://codemirror.net/demo/complete.html和 http://codemirror.net/demo/xmlcomplete.html
但是这两个触发器都在特定键上触发(Control-Space为一个,而'<'为另一个),并且都使用该extraKeys功能来处理事件,但我想从任何键触发.我尝试过以下方法:
var editor = CodeMirror.fromTextArea(document.getElementById("code"),
{
lineNumbers: true,
mode: "text/x-mysql",
fixedGutter: true,
gutter: true,
// extraKeys: {"'.'": "autocomplete"}
keyup: function(e)
{
console.log('testing');
},
onkeyup: function(e)
{
console.log('testing2');
}
});
Run Code Online (Sandbox Code Playgroud)
但没有运气.关于如何触发任何键盘事件的任何建议?
通过XCode 8构建应用程序,在Mavericks(OSX 10.9)上运行应用程序时,我收到崩溃,出现以下错误:
Apple在XCode 8发行说明中特别提到了这一点,并提供了以下详细信息:
资产目录
使用Xcode 8编译的应用程序和iOS 7的部署目标可能会在启动时崩溃,并出现以下断言:
断言失败:(maxCountIncludingZeroTerminator> 0 && tokenCount <maxCountIncludingZeroTerminator),函数CUIRenditionKeyCopy,文件/SourceCache/CoreUI/CoreUI-232.4/CoreTheme/ThemeStorage/CUIThemeRendition.m,第185行.
要解决此问题,请将部署目标更新为iOS 8.0或更高版本,或将单个映像添加到资产目录中,该资产目录在映像集中至少指定了五个属性,例如:
- 规模(1x,2x,3x)
- 成语(添加iPad,iPhone和通用资产)
- 方向(从左到右,从右到左)
- 宽度/高度等级(任何&紧凑等)
- 内存(添加1 GB资产)
- 图形(添加Metal 1v2资产)
没有必要在代码中使用图像或添加所有这些属性.(27852391)
我已经尝试将一些3x缩放图像添加到项目中,但是我仍然收到相同的异常.根据文档我只需要添加其中一个属性来解决问题,但它似乎并没有为我做的伎俩.有没有其他人遇到这个?有没有人有任何决议?
我有一个UIScrollView我正在应用黑色背景,它混合在滚动条中.我一直在寻找一种方法将滚动条颜色更改为白色,但我无法弄明白.有没有正确的方法呢?
iOS 11在输入时添加了智能引号.在macOS中,我们可以NSTextView通过设置禁用智能引号:
textView.automaticQuoteSubstitutionEnabled = NO;
Run Code Online (Sandbox Code Playgroud)
既没有UITextField或UITextView似乎没有此属性或enabledTextCheckingTypes属性.如何在iOS 11上禁用智能引号?
如果我有一个文件,我可以通过执行以下操作来获取图标:
NSImage *iconImage = [[NSWorkspace sharedWorkspace] iconForFile: @"myFile.png"];
Run Code Online (Sandbox Code Playgroud)
但是,如果我只想获取特定文件类型的图标(例如与png文件关联的图标,而没有已经存在的"myFile.png"),我不知道如何做到这一点.
任何建议表示赞赏!
objective-c ×3
c# ×2
ios ×2
cocoa ×1
codemirror ×1
com ×1
interface ×1
ios11 ×1
iphone ×1
itext ×1
javascript ×1
key-events ×1
macos ×1
pdf ×1
protocols ×1
static ×1
uiscrollview ×1
uitableview ×1
uitextfield ×1
uitextview ×1
width ×1
xcode8 ×1