Tag: 填充

Swift JSON tableview

我真的很努力parsing这个JSON( https://www.kimonolabs.com/api/7flcy3qm?apikey=gNq3hB1j0NtBdAvXJLEFx8JaqtDG8y6Y ),并用“ date ”文本,“ 事件 ”文本,“ 哈斯塔 ”文本和“ 位置 “文本。 我意识到这可能是一个非newb容易。 这是我可能很糟糕的代码: import UIKit import Foundation class MasterTableViewController: UITableViewController { var vigoData = [String]() override func viewDidLoad() { super.viewDidLoad() splitViewController!.preferredDisplayMode = UISplitViewControllerDisplayMode.AllVisible UINavigationBar.appearance().barTintColor = UIColor(red: 52.0/255.0, green: 170.0/255.0, blue: 220.0/255.0, alpha: 1.0) UINavigationBar.appearance().tintColor = UIColor.whiteColor() UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.whiteColor()] let url = NSURL(string: […]

从不同的viewControllers中填充一个CoreData实体

我在我的iPad应用程序中为我的数据库构build了一个包含不同实体的Core数据模型。 我确实想从不同的viewControllers访问这些属性(并填充dBase)。 例如,在viewController A中有UITextFields,在viewController中有另一个UITextField。 我想要获取的信息来填充我的核心数据实体的不同属性… 那可能吗? 这样做的最佳做法是什么? 我的问题: 我在viewController A中声明了types为“entity”的对象 我用查看的文本填充这个实体的不同属性,也在viewController A中 我将对象(与我的实体types相同)存储在viewController A的NSMutableArray中 我使用不同的方法来保存和检索viewController A这个NSMutableArray 任何帮助或build议,将不胜感激! 🙂

如何填充一个静态的UITableView

我尝试了几种方法,但似乎我失去了一些东西.. 这是我使用的代码: – (void)configureView { // Update the user interface for the detail item. if (self.detailItem) { for (int idx=0; idx<16; idx++) { NSIndexPath *indexPath = [[NSIndexPath alloc] initWithIndex:idx]; [self.tableView cellForRowAtIndexPath:indexPath].detailTextLabel.text = [param objectAtIndex:idx]; } self.detailDescriptionLabel.text = [self.detailItem description]; } } 我在viewDidLoad上调用这个。 我的tableview有16静态单元格,我使用标准的“小标题”types单元格,所以没有定制需要在这方面。 textLabel.text在devise时被填充。 此外我的tableview是在tableViewController。 我也尝试了标准的tableview人口,但似乎静态单元格不同意这种方式。 我究竟做错了什么? @jrturton我做了一些改变,看看发生了什么事情: 我把这三行加在一行看看有没有什么: UITableView *tv = self.tableView; UITableViewCell *cell […]

– (CGRect)textRectForBounds:(CGRect)边界没有被调用

我正在尝试移动UITextField文本,以便它正确地垂直alignment。 我在网上search,一切都指向编辑这些方法: – (CGRect) textRectForBounds:(CGRect)bounds 和 – (CGRect) editingRectForBounds:(CGRect)bounds 虽然我已经这样编辑过了: – (CGRect) textRectForBounds:(CGRect)bounds { NSLog(@"hi"); return CGRectInset(bounds, 10, 10); } 虽然它没有得到nslog。 我也尝试在文本框中调用方法,但没有成功 这是我如何初始化文本视图并设置它们: -(void) viewWillAppear:(BOOL)animated { textfield1 = [[UITextField alloc] init]; textfield2 = [[UITextField alloc] init]; textfield3 = [[UITextField alloc] init]; textfield4 = [[UITextField alloc] init]; for (UITextField *text in [NSArray arrayWithObjects:textfield1, textfield2, textfield3, textfield4, […]

结构填充编译标志

typedef struct{ char t1; long long t2; char t3; }struct_size_test; printf("sizeof(long long)==[%ld]\n", sizeof(long long)); printf("sizeof(char)==[%ld]\n", sizeof(char)); printf("sizeof(struct_size_test)==[%ld]\n", sizeof(struct_size_test)); iOS中和OS X gcc中的struct_size_test的结果是不同的。 在iOS中的结果是 sizeof(long long)==[8] sizeof(char)==[1] sizeof(struct_size_test)==[24] 但是OS X gcc的结果是 sizeof(long long)==[8] sizeof(char)==[1] sizeof(struct_size_test)==[16] 我GOOGLE了这个,并发现一些build议,添加“-malign-double”作为gcc编译标志。 但是它表明 clang: error: unknown argument: '-malign-double' [-Wunused-command-line-argument-hard-error-in-future] clang: note: this will be a hard error (cannot be downgraded to a warning) […]

在iOS / WebKit textarea中删除3个像素

我试图创build一个textarea ,看起来像一个div 。 但是,在iOS上有3个像素来自我无法删除的地方。 这是我的代码: <!doctype html> <title>Textarea test</title> <style> textarea, div { background: yellow; font: 13px arial; border: 0; padding: 0; border-radius: 0; margin: 0; -webkit-appearance: none; } </style> <div>test</div> <hr> <textarea>test</textarea> 这是这样呈现的(我放大): 如屏幕截图所示,文本之前有3像素,我想摆脱。 据我所见,这不是边际/填充或边界。 这发生在我的iPhone和iPad上,都运行iOS 4.3。 而且要清楚; 这三个额外的像素不会显示在我的桌面上的Safari / Firefox / Chrome上。 或者是我兄弟的Windows Phone。 编辑2011-08-10: 我刚刚在<input type=text>上testing了这个,并且出现了相同的“padding”,除了它是1个像素而不是3个。

将“填充”添加到UITextView

正如标题所说,我正在尝试向UITextView添加类似于填充的行为。 当视图在我的导航控制器中被推入并且出现以下代码时,生成textview: self.textView.layer.cornerRadius = 7; //pretty stuff is pretty NSString *description = appDelegate.productInDisplay.description; [self.textView setText:description]; //pretty stuff has content now CGRect frame = textView.frame; frame.size.height = textView.contentSize.height; textView.frame = frame; //set the UITextView to the size of it's containing text. self.textView.editable = NO; self.theScrollView.contentSize = CGSizeMake(320, 250 + textView.frame.size.height); //set the parent scrollView's height to […]

UIImage用另一个图像填充透明部分

我想用iOS中的另一个图像填充图像的透明部分。 我已经尝试了一些与UIGraphicsContext东西,但我不能得到它的工作,因为我从来没有使用过。 这是图像: 我试过一些代码: UIImageView *v = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 70, 70)]; UIGraphicsBeginImageContextWithOptions(v.frame.size, YES, 0); CGContextRef context = UIGraphicsGetCurrentContext(); // beach image UIImage *img = [UIImage imageNamed:@"zivogosce_camping_05.jpg"]; //[img drawInRect:CGRectMake(2, 0, 12, 12)]; UIImage *annotationImg = [UIImage imageNamed:@"custom_annotation"]; [annotationImg drawAtPoint:CGPointMake(0, 0)]; CGContextSetFillColorWithColor(context, [[UIColor colorWithPatternImage:img] CGColor]); CGContextFillRect(context, CGRectMake(0, 0, 50, 50)); CGContextDrawImage(context, CGRectMake(0, 0, v.frame.size.width, v.frame.size.height), […]

iOS Swift Flood填充algorithm

我为触点的“桶填充”(填充)创build了这个扩展: extension UIImageView { func bucketFill(startPoint: CGPoint, newColor: UIColor) { var newRed, newGreen, newBlue, newAlpha: CUnsignedChar let pixelsWide = CGImageGetWidth(self.image!.CGImage) let pixelsHigh = CGImageGetHeight(self.image!.CGImage) let rect = CGRect(x:0, y:0, width:Int(pixelsWide), height:Int(pixelsHigh)) let bitmapBytesPerRow = Int(pixelsWide) * 4 var context = self.image!.createARGBBitmapContext() //Clear the context CGContextClearRect(context, rect) // Draw the image to the bitmap context. Once […]

Objective-C的代码,以正确的垫NSString?

有人可以给一个代码示例如何在Objective-C中正确填充NSString吗? 比如想要这些string: Testing 123 Long String Hello World Short 如果右填充到12的列宽度,然后在每个的末尾添加一个刺痛的“XXX”,则会给出: Testing 123 xxx Hello World xxx Short xxx 这是第二列想起来。