小编QED*_*QED的帖子

使用CGContext绘制线条

我想用CGContext绘制一条线,到目前为止我是:

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor);
CGContextSetLineWidth(context, 1.0f);
CGContextMoveToPoint(context, 10, 10); 
CGContextAddLineToPoint(context, 100, 50);
CGContextStrokePath(context);
Run Code Online (Sandbox Code Playgroud)

它总是从左上角到右下角的顶部.如何调整此线的起点和终点?如何调整线的长度?

iphone objective-c cgcontext ipad ios

7
推荐指数
2
解决办法
2万
查看次数

Facebook Graph API是否有版本控制方案?

标题说明了一切.我仔细阅读了在线文档,GitHub存储库,代码本身.它有没有版本字符串?(真的有关系吗?)

api facebook

6
推荐指数
1
解决办法
368
查看次数

如何隐藏WebView错误页面.可能吗?

我搜索并发现了类似的问题,但他们主要说如何更改webView内容,而不是如何真正隐藏它.

我的webView最初是在main.xml中使用android:visibility ="gone"隐藏的,我用myWebView.setVisibility(1)将其改为dinamically to visible!当页面完全加载(并且它工作).现在,我想在检测到错误时隐藏此webView.我想隐藏它的原因是因为我在布局中有一个很好的背景,可以告知错误.我知道这不是最好的方法,可能会在以后更改它,但现在,我想解决的是为什么webView在发生错误时没有隐藏(只是为了好玩,也许).

这就是我尝试过的:

@Override
public void onReceivedError (WebView view, int errorCode, 
                             String description, String failingUrl) {

        myWebView = (WebView) findViewById(R.id.webview);  
        // myWebView.setVisibility(0); // Doesn't work!

        // if (errorCode == ERROR_TIMEOUT) { // Commented just for trying

        try {view.stopLoading();} catch(Exception e){}
        try {view.clearView();} catch(Exception e){}

            view.loadUrl("file:///android_asset/error.html"); // This Works but I don't want it this way.
            view.setBackgroundColor(0x00000000); // Trying to make it transparent. Doesn't work here
            view.setVisibility(View.GONE); // Doesn't work. I have tried also with myWebView.
            //  } …
Run Code Online (Sandbox Code Playgroud)

error-handling android webview

6
推荐指数
1
解决办法
2031
查看次数

我是否需要从数据源的cellForPath中调用UICollectionView的dequeueCell:?

我真的,真的想为我的UICollectionView提供'静态'单元格,以及UITableView的旧时代.但我知道我们好男孩和女孩必须dequeueReusableCellWithReuseIdentifier:forIndexPath:用作我们细胞的工厂.所以我建议采用以下方案,并就其潜力提出反馈意见.到目前为止,它对我有用,但我害怕一个未知的陷阱.

#import "MyCellClass.h"

@implementation MyViewController {
   MyCellClass *_cell0; // etc - many are possible. could store in array
}

-(void)viewDidLoad {
   // assume MyCellClass has a +nib and +reuseId. The reader understands.
   [_collectionView registerNib:[MyCellClass nib] forCellWithReuseIdentifier:[MyCellClass reuseId]];
}

-(void)viewDidAppear:animated {
   // this is where the fun begins. assume proper counts coming from the datasource
   NSIndexPath *indexPath = [NSIndexPath indexPathWithRow:0 inSection:0];
   _cell0 = [[self collectionView] dequeueReusableCellWithReuseIdentifier:[MyCellClass reuseId] forIndexPath:indexPath];
   // etc
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
   if ([indexPath …
Run Code Online (Sandbox Code Playgroud)

ios uicollectionview

6
推荐指数
1
解决办法
9297
查看次数

CoreData to-many添加错误

不知道我在这里做错了什么.

学校对学生有很多,学生有反向. 在此输入图像描述


在此输入图像描述


一点测试代码如下:

@class Student;

@interface School : NSManagedObject

@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSOrderedSet *students;
@end

@interface School (CoreDataGeneratedAccessors)

- (void)insertObject:(Student *)value inStudentsAtIndex:(NSUInteger)idx;
- (void)removeObjectFromStudentsAtIndex:(NSUInteger)idx;
- (void)insertStudents:(NSArray *)value atIndexes:(NSIndexSet *)indexes;
- (void)removeStudentsAtIndexes:(NSIndexSet *)indexes;
- (void)replaceObjectInStudentsAtIndex:(NSUInteger)idx withObject:(Student *)value;
- (void)replaceStudentsAtIndexes:(NSIndexSet *)indexes withStudents:(NSArray *)values;
- (void)addStudentsObject:(Student *)value;
- (void)removeStudentsObject:(Student *)value;
- (void)addStudents:(NSOrderedSet *)values;
- (void)removeStudents:(NSOrderedSet *)values;
@end



// Meanwhile, elsewhere...
-(void)go {
   AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];
   NSManagedObjectContext *context = [app managedObjectContext];

   School *school = …
Run Code Online (Sandbox Code Playgroud)

core-data one-to-many ios

6
推荐指数
1
解决办法
5169
查看次数

在iOS7中删除UITabBar水平分隔符

我想删除UITabBar和屏幕其余部分之间的水平分隔线.我问的是这个家伙的问题,但是针对iOS7进行了更新.

设置我的UITabBar的背景图像不会缓解问题,也不会设置[UITabBar appearance]对象的背景图像.

这在iOS7中仍然可行吗?如果是这样,怎么样?

user-experience uitabbar ios7

3
推荐指数
1
解决办法
2700
查看次数

使用“是/否”对话框拦截链接 LinkMovementMethod

LinkMovementMethod我建立了一个标准,TextView当用户触摸链接时推送某种网络活动。但是,我想建立一个“您想查看链接吗”对话框,而不是将用户直接带到网页。我尝试过重写触摸方法,但这一切都变得有点复杂。一点帮助?

android linkmovementmethod

3
推荐指数
1
解决办法
2105
查看次数

以下iOS代码是否安全?(__autoreleasing语义)

-(NSData *)jsonRepresentation:(NSError **error)error {
   NSDictionary *dict = [self getDictRepresentation];
   return [NSJSONSerialization dataWithJSONObject:dict options:nil error:error];
}

// Some other place...

NSError *__autoreleasing error = nil;
NSData *json = [obj jsonRepresentation:&error];
Run Code Online (Sandbox Code Playgroud)

自动释放语义是否安全地将error堆栈传送到我的第二个代码块?

autorelease ios automatic-ref-counting

2
推荐指数
1
解决办法
156
查看次数

AdMob问题和错误

我正在尝试将AdMob应用到我的iOS应用中.我按照他们在这里提供的文档.所以我尝试构建并运行,我收到以下错误:

Undefined symbols for architecture i386:
  "_NSOverwriteMergePolicy", referenced from:
      anon in libGoogleAnalyticsServices.a(GAIDataStore.o)
      anon in libGoogleAnalyticsServices.a(TAGModel.o)
      anon in libGoogleAnalyticsServices.a(GAIDataStore.o)
      anon in libGoogleAnalyticsServices.a(TAGModel.o)
  "_NSSQLiteErrorDomain", referenced from:
      anon in libGoogleAnalyticsServices.a(GAIDataStore.o)
  "_NSSQLiteStoreType", referenced from:
      anon in libGoogleAnalyticsServices.a(GAIDataStore.o)
      anon in libGoogleAnalyticsServices.a(TAGModel.o)
      anon in libGoogleAnalyticsServices.a(GAIDataStore.o)
      anon in libGoogleAnalyticsServices.a(TAGModel.o)
  "_OBJC_CLASS_$_MFMailComposeViewController", referenced from:
      objc-class-ref in libGoogleAdMobAds.a(GADOpener.o)
  "_OBJC_CLASS_$_MFMessageComposeViewController", referenced from:
      objc-class-ref in libGoogleAdMobAds.a(GADOpener.o)
  "_OBJC_CLASS_$_NSAttributeDescription", referenced from:
      objc-class-ref in libGoogleAnalyticsServices.a(GAICoreDataUtil.o)
      objc-class-ref in libGoogleAnalyticsServices.a(TAGModel.o)
  "_OBJC_CLASS_$_NSEntityDescription", referenced from:
      objc-class-ref in libGoogleAnalyticsServices.a(GAIDataStore.o)
      objc-class-ref in libGoogleAnalyticsServices.a(GAICoreDataUtil.o)
      objc-class-ref in libGoogleAnalyticsServices.a(TAGDataProvider.o)
      objc-class-ref in libGoogleAnalyticsServices.a(TAGModel.o) …
Run Code Online (Sandbox Code Playgroud)

ads linker-errors admob ios

2
推荐指数
1
解决办法
5782
查看次数

从 BeautifulSoup 对象获取 URL

有人将他使用典型调用获得的 BeautifulSoup 对象 (BS4) 交给我的函数:

soup = BeautifulSoup(url)
Run Code Online (Sandbox Code Playgroud)

我的代码:

def doSomethingUseful(soup):
    url = soup.???
Run Code Online (Sandbox Code Playgroud)

如何从汤对象中获取原始 URL?我试着阅读文档和 BeautifulSoup 源代码......我仍然不确定。

python beautifulsoup

1
推荐指数
1
解决办法
7960
查看次数

Perl数组转储

我这样做:

my @items = [];

sub pushItem {
   my $itemId = "i" . sprintf("%d", $_[0]);
   push(@items, $itemId);
}

sub popItems {
   $itemsXml = "<key>items</key>\n<array>\n";

   foreach (@items) {
      $itemsXml .= "<string>$_</string>\n";
   }

   $itemsXml .= "</array>\n";

   return $itemsXml;
}

pushItem(0);
pushItem(1);
pushItem(2);
print popItems();
Run Code Online (Sandbox Code Playgroud)

我明白了:

 <key>items</key>
 <array>
 <string>ARRAY(0x7fa1730070d0)</string>
 <string>i0</string>
 <string>i1</string>
 <string>i2</string>
 </array>
Run Code Online (Sandbox Code Playgroud)

问题当然是:

<string>ARRAY(0x7fa1730070d0)</string>
Run Code Online (Sandbox Code Playgroud)

arrays perl output

0
推荐指数
1
解决办法
57
查看次数

Swift 中的 Objective-C NS_OPTIONS

NS_OPTIONS在 Objective-C 中给出了一个定义:

typedef NS_OPTIONS(NSInteger, MyType) {
   MyTypeOption1 = 1 << 0,
   MyTypeOption2 = 1 << 1,
   MyTypeOption3 = 1 << 2,
   // etc
}
Run Code Online (Sandbox Code Playgroud)

我正在将此类型导入 Swift,但无法形成位字段。

let default : MyType = MyTypeOption1 | MyTypeOption2
Run Code Online (Sandbox Code Playgroud)

错误:

Protocol 'BinaryInteger' requires that 'MyType' conform to 'BinaryInteger'
Run Code Online (Sandbox Code Playgroud)

IDE 表明问题出在常设冒号按位或运算符。

改变NS_OPTIONS声明或用 Swift 声明新类型OptionSet不是……选项。我怎样才能让 Swift 打球?

objective-c bit-fields swift

-2
推荐指数
1
解决办法
912
查看次数