我有一个cocoapod库,其中包含2种格式的资产:
我的podspec
文件包含资源包的定义:
s.resource_bundle = {'SparkSetup' => ['Resources/**/*.{xcassets,storyboard}']}
Run Code Online (Sandbox Code Playgroud)
我在pod项目中有一个单独的目标,通过使用这些文件+该包的plist文件来创建资源包.
事情是,当我在应用程序项目中使用pod时 - 我可以看到storyboard/xcassets文件位于pod目标中,我可以轻松访问和运行故事板,但故事板中引用的图像(到.xcassets文件)是在运行时未找到(但在IB中正确显示).
我得到的错误是:
Could not load the "spinner" image referenced from a nib in the bundle with identifier "(null)"
Run Code Online (Sandbox Code Playgroud)
我确实在products目录中看到了一个bundle文件.要在故事板中实现VC,我使用:
+(NSBundle *)getResourcesBundle
{
NSBundle *bundle = [NSBundle bundleWithURL:[[NSBundle mainBundle] URLForResource:@"SparkSetup" withExtension:@"bundle"]];
return bundle;
}
+(UIStoryboard *)getSetupStoryboard
{
UIStoryboard *setupStoryboard = [UIStoryboard storyboardWithName:@"setup" bundle:[SparkSetupMainController getResourcesBundle]];
return setupStoryboard;
}
Run Code Online (Sandbox Code Playgroud)
这似乎很适合找到故事板,但不适用于在同一捆绑中的.xcassets中查找图像.
我究竟做错了什么?如何从这个故事板/代码中引用图像,并能够将此UI pod集成到任何应用程序中?
谢谢!
我正在尝试使用以下代码在我的UITableViewCells的特定行上显示"挂锁"图标:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TopicCell"];
GPBTopic *topic = [self.topics.list objectAtIndex:indexPath.row];
cell.textLabel.text= topic.name;
if ((indexPath.row == 5) || (indexPath.row == 9))
{
cell.accessoryView = [[ UIImageView alloc ] initWithImage:[UIImage imageNamed:@"lock_icon.png"]];;
[cell.accessoryView setFrame:CGRectMake(0, 0, 24, 24)];
}
return cell;
}
Run Code Online (Sandbox Code Playgroud)
我得到了一个有趣的结果 - 挂锁最初显示在第5,9行,但是当我向下滚动列表时,图标会在其他单元格的accessoryView上随机重新显示(只有1个部分顺便说一句),并且滚动变得非常生涩和滞后......我向上/向下滚动的越多,它的实例就越多!为什么?这里的错误在哪里?
帮忙,谢谢!
在iOS上使用AFNetworking编写多部分PUT请求的正确方法是什么?(仍然是Objective-C,而不是Swift)
我看起来好像AFNetworking可以做多部分POST
而不是PUT
,那是什么解决方案?
谢谢
我正在尝试将数据从本机iOS应用程序传输到在UIWebView中运行的React(非反应原生)Web应用程序.
我从本地viewcontroller获取一个字符串,需要将其"注入"到<input>
React组件类中的元素值.我给元素id
这样:
render() {
<div>
...
<input id="iccid" type="text" name="iccid" pattern="\d*" onChange={this.iccidChanged.bind(this)} autoFocus />
...
</div>
}
Run Code Online (Sandbox Code Playgroud)
然后使用iOS的JavaScriptCore(Swift代码)运行:
self.context = self.webView.valueForKeyPath("documentView.webView.mainFrame.javaScriptContext") as? JSContext
self.context!.evaluateScript("document.getElementById('iccid').value='\(barcodeValue)';")
Run Code Online (Sandbox Code Playgroud)
这似乎工作得很好,我可以看到在webview中的DOM更新的值,问题是我的React onChange
函数(验证值和更改组件状态)不会触发,因为React不会将此解释为更改(可能是因为DOM与虚拟DOM处理).
从iOS更新元素值的正确方法/最佳实践是什么?让React组件表现得像用户输入的那样?
我有一个已发布的Cocoapod,说它的名字abc-sdk
,我希望修改它的名字(大写)Abc-SDK
.可能吗?我尝试更改s.name
podspec(以及podspec文件名大小写)但是当我运行时pod trunk push
我得到:
[!] The following validation failed:
- Name is already taken.
什么是正确的方法呢?
试图建立一个Cocoapod库,它依赖于我拥有的其他已发布的Cocoapod库,让XCode中的项目构建正常,但运行pod lib lint
命令检查pod有效性失败了
error: include of non-modular header inside framework module
,库的头文件(pod)我依赖于.所有来源都是Obj-C而不是Swift.
根据这里的建议,我确实尝试了以下内容
public
而不是project
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES =
YES
为每个目标设置public
.但问题仍然存在,我无法发布pod也无法测试它.
当我s.dependency 'OldPodIDependOn'
在我的新pod的podspec文件中注释掉该行时更新,
然后错误消失,但找不到相关标头.如果我不包括我依赖Podfile
的./Example
文件夹下的pod ,如下所示:
target 'NewPod', :exclusive => true do
pod "NewPod", :path => "../"
pod "OldPodIDependOn", :path => "../../OldPodIDependOn/"
end
Run Code Online (Sandbox Code Playgroud)
然后项目将不会在XCode中构建,因为OldPodIDependOn
文件不是项目的一部分.有一点鸡蛋或鸡蛋问题.
更新2
还尝试删除:path => "../../OldPodIDependOn/"
组件以引用已发布的窗格而不是本地窗格 - 没有帮助.
值得一提的是,这个pod将包含一个UI,因此将包含和引用一个故事板,我s.resources = 'Pod/Classes/UI/NewPod.storyboard'
在podspec文件中添加了一行,并从pod目标编译源中删除了故事板(否则xcode将无法构建).我不认为这与问题有关,但值得一提,也许我在那里做错了.
我究竟做错了什么?任何帮助将不胜感激!
这些是什么?
特别是A/M /?在一些文件附近标记?每个字母是什么意思?
这是我从之前的xcode版本(和iOS 4)导入的项目.这些项目编译得很好.我的新故事板/ iOS 5项目没有显示这些标记.它们代表什么,我如何设置/重置这些?
谢谢
我的cocoapod的podspec包含资源包的子规范:
s.subspec 'Resources' do |resources|
resources.resource_bundle = {'SparkSetup' => ['Resources/**/*']}
end
Run Code Online (Sandbox Code Playgroud)
Resources文件夹包含格式Images.xcassets(普通XCode格式)的资产目录.我的项目包含两个目标 - 主lib目标和资源包目标,其中包含故事板和上述资产目录文件.我引用了主要的lib代码.没有问题.
当pod lib lint
我想要得到:
2015-08-25 18:51:56.495 ruby[12181:184219] warning: The file reference for "Contents.json" is a member of multiple groups ("1.imageset" and "2.imageset"); this indicates a malformed project. Only the membership in one of the groups will be preserved (but membership in targets will be unaffected). If you want a reference to the same file in more than one group, please add another reference to the …
Run Code Online (Sandbox Code Playgroud) 如何将一个简单的UILabel添加到TableHeaderView并保留iOS7中搜索显示控制器的默认搜索栏行为?
或者,视觉上:
为什么这段代码:
UIView *tableHeadView = self.tableView.tableHeaderView;
UILabel *tableHeaderLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 36, 320, 30)];
[tableHeaderLabel setTextAlignment:NSTextAlignmentCenter];
tableHeaderLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:18];
tableHeaderLabel.text = @"Questions"
UILabel *tableHeaderPrononce = [[UILabel alloc] initWithFrame:CGRectMake(0, 50, 320, 30)];
[tableHeaderPrononce setTextAlignment:NSTextAlignmentCenter];
tableHeaderPrononce.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:15];
tableHeaderPrononce.text = @"test test test test";
[tableHeadView addSubview:tableHeaderLabel];
[tableHeadView addSubview:tableHeaderPrononce];
Run Code Online (Sandbox Code Playgroud)
添加到UITableViewController viewDidLoad事件(包含一个UISearchDisplayerController)在iOS6中给出了这个可爱的结果:
这个在iOS7中可怕的糟糕结果:
行为: 在正常模式下,我添加的UILabel未显示.当搜索处于活动状态时,UILabels突然出现在表格单元格的顶部,并且不会滚动
此外,我在iOS 7中搜索时遇到崩溃,这在iOS6上从未发生过.可能与这段代码没有关系,但我应该提到这一点.
我尝试了所有我能找到的关于解决这个问题的东西,但总是其他东西破坏或消失(主要是UISearchBar).
救命
ios ×10
xcode ×6
objective-c ×5
cocoapods ×4
iphone ×2
uitableview ×2
afnetworking ×1
ios7 ×1
javascript ×1
reactjs ×1
rest ×1
swift ×1
uiwebview ×1