我有两个UIActionSheets,我想我将用一个委托(实例化它们的UIViewController)来控制它们.委托将捕获一个actionSheet调用,并试图找出两个中的哪一个抛出事件.
我试图让modalView的标题区别开来,但似乎无效......
这有用吗?
如果没有,是否有其他方法来区分哪个UIActionSheet做了事件?
或者我是否需要为每个UIActionSheet创建两个不同的类,这些类将是单独的委托?
提前致谢.
在解决方案中引用项目的最佳方法是什么?
我通过添加参考 - >项目添加了参考.但它链接到释放DLL或调试DLL.
我希望项目本身在引用中,当我们编译项目时,必须编译所有引用项目(通过依赖项).
这该怎么做?
我在同一个UITableView中插入和删除UITableViewCells时遇到了很多麻烦!
我通常不发布代码,但我认为这是显示我遇到问题的最佳方式:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 5;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (iSelectedSection == section) return 5;
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//NSLog(@"drawing row:%d section:%d", [indexPath row], [indexPath section]);
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
if (iSelectedSection == [indexPath section]) {
cell.textColor = [UIColor redColor];
} else {
cell.textColor = [UIColor blackColor];
}
cell.text = …Run Code Online (Sandbox Code Playgroud) 我正在尝试绘制一个水平无限大的图形,与屏幕的高度相同.我在其中添加了一个UIScrollView和一个UIView的子类,它实现了该-drawRect:方法.在模拟器中,一切正常,但在设备上,它似乎无法在图形达到一定大小后绘制.
我已经尽可能地缓存了所有内容,并且基本上只在该-drawRect:部分中调用CGContextAddLineToPoint .我只画出屏幕上可见的内容.我有一个UIScrollView的委托,它监听-scrollViewDidScroll:,然后告诉图形重绘自己([graphView setNeedsDisplay]).
我发现一个方法告诉我重写+layerClass方法并返回[CATiledLayer class].这确实允许图形实际在设备上绘制,但它的功能非常差.实际绘制的速度非常慢,并且发生的淡入淡出是不可取的.
有什么建议?
编辑:非常感谢所有的答案.以下是目前应用优化后的结果:
非常好的部分是这不需要在iphone代码中进行任何更改
我有一个iphone应用程序,其中包含一个以sqlite格式保存的大型字典(只读).我正在寻找减少DB文件大小的想法,目前这个文件非常大.
以下是sqlite DB的条目数和结果大小:
franks-macbook:DictionaryMaker frank$ ls -lh dictionary.db
-rw-r--r-- 1 frank staff 59M 8 Oct 23:08 dictionary.db
franks-macbook:DictionaryMaker frank$ wc -l dictionary.txt
453154 dictionary.txt
Run Code Online (Sandbox Code Playgroud)
...每个条目平均大约135个字节.
这是我的数据库架构:
create table words (word text primary key, sowpods boolean, twl boolean, signature text)
create index sowpods_idx on words(sowpods)
create index twl_idx on words(twl)
create index signature_idx on words(signature)
Run Code Online (Sandbox Code Playgroud)
以下是一些示例数据:
photoengrave|1|1|10002011000001210101010000
photoengraved|1|1|10012011000001210101010000
photoengraver|1|1|10002011000001210201010000
photoengravers|1|1|10002011000001210211010000
photoengraves|1|1|10002011000001210111010000
photoengraving|1|1|10001021100002210101010000
Run Code Online (Sandbox Code Playgroud)
最后一个字段表示字谜检索的字母频率(每个位置在0..9范围内).两个布尔代表子词典.
我需要做以下的查询:
select signature from words where word = 'foo'
select …Run Code Online (Sandbox Code Playgroud) 我有一个看起来像这样的课程:
@interface Properties : NSObject {
@private
NSNumber* prop1;
NSNumberBool* prop2;
//etc
Run Code Online (Sandbox Code Playgroud)
其中NSNumberBool是typedef:
// in MyApp_Prefix.pch
typedef NSNumber NSNumberBool;
Run Code Online (Sandbox Code Playgroud)
我有所有必需的@property和@synthesize声明来制作prop1和prop2属性.
所有编译和工作正常,直到我试图通过[myProperties valueForKey:@"prop2"]访问prop2.这给了我一个"类不符合键值"的错误.但是,许多类似的调用工作正常:
myProperties.prop2; //works
[myProperties prop2]; //works
[myProperties valueForKey:@"prop1"]; //works
[myProperties valueForKey:@"prop2"] // throws NSUnknownKeyException ??
Run Code Online (Sandbox Code Playgroud)
这里发生了什么,我该如何解决?
谢谢,
来自C背景,"链接框架"和"其他框架"是什么意思?
看看我的构建目标,我看到Linked Frameworks实际上是链接的(动态地,我认为 - 静态链接如何工作?)
什么是"其他框架"呢?
为了测试,我在文件中使用了Foundation定义的NSString类.基础是在其他框架中,并没有与目标链接.
唉,编译完成没有警告,可执行文件运行.
我尝试过各种各样的东西,包括:
[timepicker setDate: [NSDate mondayalarmtime]];
Run Code Online (Sandbox Code Playgroud)
和
timepicker.date = mondayalarmtime;
Run Code Online (Sandbox Code Playgroud)
每次,这条线都会使模拟器崩溃.我的mondayalarmtime在viewDidLoad中定义:
NSDateFormatter *inputFormat = [[NSDateFormatter alloc] init];
[inputFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate *inputDate = [inputFormat dateFromString: @"2011-01-01 09:00:00"];
NSLog (@"The input date %@", inputDate);
NSDate *mondayalarmtime = inputDate;
Run Code Online (Sandbox Code Playgroud)
NSLog返回:
The input date 2011-01-01 09:00:00 +0000
Run Code Online (Sandbox Code Playgroud)
在尝试将imepicker设置为mondayalarmtime之前,将NSLog请求mondayalarmtime返回相同的..
Mondays alarm time.. 2011-01-01 09:00:35 +0000
Run Code Online (Sandbox Code Playgroud)
然后当它尝试将timepicker日期设置为mondayalarmtime时,它会与报告崩溃:
Program received signal: “EXC_BAD_ACCESS”.
Run Code Online (Sandbox Code Playgroud) 我几乎没有使用python的经验,但我正在尝试创建一个简单的脚本来加载图像并使用滑块小部件来调整颜色条的最小值和最大值,并相应地重新绘制图像数据.
我试图遵循这个例子:http://matplotlib.sourceforge.net/examples/widgets/slider_demo.html.我试图将plot命令更改为imshow,并使用滑块值设置我的图像的爬升.但是,我从调用'im1,= ax.imshow'(在下面的代码的第12行)中收到以下错误消息:
'AxesImage'对象不可迭代
我不明白这个调用是做什么的,但显然它不能与imshow()一起使用.如果我删除该调用中的逗号,则不会出现错误,但更改滑块时图像不会更新.有没有人有替代解决方案,或解释为什么这不起作用?任何帮助将不胜感激,谢谢.
我的代码如下:
from pylab import *
from matplotlib.widgets import Slider, Button, RadioButtons
import matplotlib.pyplot as plt
import numpy as np
close('all')
ax = subplot(111)
subplots_adjust(left=0.25, bottom=0.25)
min0 = 0
max0 = 25000
im=np.loadtxt('im.txt')
im1,=ax.imshow(im)
colorbar()
axcolor = 'lightgoldenrodyellow'
axmin = axes([0.25, 0.1, 0.65, 0.03], axisbg=axcolor)
axmax = axes([0.25, 0.15, 0.65, 0.03], axisbg=axcolor)
smin = Slider(axmin, 'Min', 0, 30000, valinit=min0)
smax = Slider(axmax, 'Max', 0, 30000, valinit=max0)
def update(val):
im1.set_clim=(smin.val,smax.val)
draw()
smin.on_changed(update)
smax.on_changed(update) …Run Code Online (Sandbox Code Playgroud) cocoa-touch ×4
iphone ×4
objective-c ×2
cocoa ×1
compilation ×1
compression ×1
insert ×1
matplotlib ×1
nsdate ×1
nstokenfield ×1
python ×1
ruby ×1
sqlite ×1
typedef ×1
uidatepicker ×1
widget ×1
xcode ×1