我添加了一个动作方法来查看控制器并按住Ctrl键将按钮拖动到故事板中的"退出"图标,并且成功创建了展开segue.但是当我触摸按钮时,展开segue不起作用(当前场景不起作用)导航到原始场景)并且没有触发动作方法.我不知道为什么.
这是动作方法
@interface HMCViewController2 : UIViewController
-(IBAction)return:(UIStoryboardSegue *)segue;
@end
@implementation HMCViewController2
...
-(IBAction)return:(UIStoryboardSegue *)segue{
}
@end
Run Code Online (Sandbox Code Playgroud)
我将项目上传到谷歌驱动器.
首先,我将UISwipeGestureRecognizer附加到图像视图,无法触发操作方法.然后我附加UISwipeGestureRecognizer来查看控制器的视图,它运行良好.我不知道为什么.这是不起作用的代码
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
UISwipeGestureRecognizer *swipeRight=[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRightAction)];
swipeRight.direction=UISwipeGestureRecognizerDirectionRight;
//imageView is an outlet of image view
[imageView addGestureRecognizer:swipeRight];
}
Run Code Online (Sandbox Code Playgroud)
这是运行良好的代码
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
UISwipeGestureRecognizer *swipeRight=[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRightAction)];
swipeRight.direction=UISwipeGestureRecognizerDirectionRight;
//imageView is an outlet of image view
[self.view addGestureRecognizer:swipeRight];
}
Run Code Online (Sandbox Code Playgroud) 我在Mac上用OS X 10.9运行节点服务器.这是代码
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(3000, '0.0.0.0');
console.log('Server running at http://192.168.1.120:3000/');
Run Code Online (Sandbox Code Playgroud)
我可以在我的Mac上使用Safari来访问服务器http://192.168.1.120:3000/.但是当我用我的iPhone访问服务器时,它失败了.我的Mac的防火墙已关闭,而我的iPhone与Mac的WiFi相同.
我只知道CCNode的旋转属性可能与它有关.但我想水平翻转一个精灵,而不是旋转.
当我不使用纹理图集时,一切都运行正常.但是当我使用纹理图集时,animateWithTextures不起作用而且什么都没有出现.这是我的代码
SKTexture *spaceshipTexture = [SKTexture textureWithImageNamed:@"monkey.png"];
SKSpriteNode *spaceship = [SKSpriteNode spriteNodeWithTexture:spaceshipTexture];
spaceship.position = CGPointMake(0,0);
spaceship.anchorPoint = CGPointMake(0,0);
[self addChild: spaceship];
NSMutableArray *images=[NSMutableArray arrayWithCapacity:14];
for (int i=1; i<=14; i++) {
NSString *fileName=[NSString stringWithFormat:@"%dShuGuangx.png",i];
SKTexture *tempTexture=[SKTexture textureWithImageNamed:fileName];
[images addObject:tempTexture];
}
NSLog(@"count %d",images.count);
SKAction *walkAnimation = [SKAction animateWithTextures:images timePerFrame:0.1];
[spaceship runAction:walkAnimation];
Run Code Online (Sandbox Code Playgroud) 在我的视图控制器中,我向self.view添加了一个UITapGestureRecognizer.我在self.view上添加了一个小视图.当我点击小视图时,我不想在self.view中触发UITapGestureRecognizer事件.这是我的代码,它不起作用.
- (void)viewDidLoad {
[super viewDidLoad];
UITapGestureRecognizer *_tapOnVideoRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toggleControlsVisible)];
[self.view addGestureRecognizer:_tapOnVideoRecognizer];
UIView *smallView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
smallView.backgroundColor=[UIColor redColor];
smallView.exclusiveTouch=YES;
smallView.userInteractionEnabled=YES;
[self.view addSubview:smallView];
}
- (void)toggleControlsVisible
{
NSLog(@"tapped");
}
Run Code Online (Sandbox Code Playgroud)
当我点击小视图时,它仍会在self.view中触发点击事件.Xcode记录"轻拍".如何拦截从smallView到self.view的手势事件?
我编写了一个简单的iOS程序来使用React Native显示图像.
'use strict';
var React = require('react-native');
var {
Image
} = React;
var styles = React.StyleSheet.create({
base: {
height: 400,
width: 400
}
});
class SimpleApp extends React.Component {
render() {
return (
<Image
style={styles.base}
source={require('image!k')}
//source={{uri: 'http://news.xinhuanet.com/world/2015-05/09/127782089_14311512601821n.jpg'}}
/>
)
}
}
React.AppRegistry.registerComponent('SimpleApp', () => SimpleApp);
Run Code Online (Sandbox Code Playgroud)
但是我从iPad屏幕上收到了消息:
"Failed to print error:","'undefined' is not an object (evaluating 'stackString.split')"
Run Code Online (Sandbox Code Playgroud)
当我更改代码以使用图像网址时
//source={require('image!k')}
source={{uri: 'http://news.xinhuanet.com/world/2015-05/09/127782089_14311512601821n.jpg'}}
Run Code Online (Sandbox Code Playgroud)
我只得到一个红色的矩形边框.
当我使用另一个js文件时,一切运行良好."Hello World"可以在iPad屏幕上显示.
'use strict';
var React = require('react-native');
var {
Text,
} = React;
class SimpleApp …Run Code Online (Sandbox Code Playgroud) 我使用WKWebView加载网页。当用户单击网页中的按钮时,我的网页将打开一个自定义架构URL(例如asfle:// download?media_id = 1)。我使用KVO观察WKWebView的URL属性以获取URL。它在iOS 9中很好用,但在iOS 10中不起作用。我无法获取URL。我使用Xcode 8,Swift 2.3。
override func viewDidLoad() {
super.viewDidLoad()
webView.addObserver(self, forKeyPath: "URL", options: .New, context: nil)
}
override func observeValueForKeyPath(keyPath: String?,
ofObject object: AnyObject?,
change: [String : AnyObject]?,
context: UnsafeMutablePointer<Void>)
{
print("url?\(webView.URL)")
}
Run Code Online (Sandbox Code Playgroud)
在iOS 9中,它可以打印网址。但是在iOS 10中,仅打印网站的url,当用户触摸网页中的按钮时,不会打印任何内容。
我想为UIView添加摇动效果,但我失败了.我的代码也是
CGRect rectL=CGRectMake(473, 473, 88, 88);
CGRect rectR=CGRectMake(493, 473, 88, 88);
NSValue *valueL = [NSValue value: &rectL
withObjCType:@encode(CGRect)];
NSValue *valueR = [NSValue value: &rectR
withObjCType:@encode(CGRect)];
NSArray *firstArray=@[valueL,valueR,valueL,valueR,valueL,valueR,valueL,valueR];
[UIView animateWithDuration:2 animations:^{
CAKeyframeAnimation * theAnimation;
// Create the animation object, specifying the position property as the key path.
theAnimation=[CAKeyframeAnimation animationWithKeyPath:@"frame"];
theAnimation.values=firstArray;
theAnimation.duration=5.0;
theAnimation.calculationMode= kCAAnimationLinear;
// Add the animation to the layer.
[self.boView.layer addAnimation:theAnimation forKey:@"frame"];//boView is an outlet of UIView
}completion:^(BOOL finished){
}];
Run Code Online (Sandbox Code Playgroud)
当我运行代码时,视图仍然没有抖动.为什么?
UPDATE
我必须使用关键帧动画,因为在视图抖动之后,它需要移动到另一个地方,然后摇动然后停止.这是我编辑的代码,但它仍然不起作用.为什么?
CGRect rectL=CGRectMake(463, 473, 88, 88);
CGRect rectR=CGRectMake(503, …Run Code Online (Sandbox Code Playgroud) 我在iOS项目中使用FMDB.但是当我用FMDB读取ROWID时,Xcode日志"警告:我找不到名为'rowid'的列."
...
//Create database
NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *dbPath = [documentsPath stringByAppendingPathComponent:@"bookmarksDatabase.sqlite"];
BOOL needCreateTable = ![[NSFileManager defaultManager] fileExistsAtPath:dbPath];
FMDatabase *db = [FMDatabase databaseWithPath:dbPath];
[db open];
if (needCreateTable) {
[db executeUpdate:@"CREATE TABLE bookmarks (title TEXT ,url TEXT ,folderID INTEGER ,locationIndex INTEGER)"];
}
else
{
[self reloadBookmarkDatabase:db];
}
[db close];
...
//Read database. Only "ROWID" column can't find.
FMResultSet *results = [db executeQuery:@"SELECT * FROM bookmarks ORDER BY locationIndex"];
while([results next]) {
BookmarkData *temp = [[BookmarkData alloc] initWithID:[results …Run Code Online (Sandbox Code Playgroud) 我正在iOS项目中使用VLCKit(MobileVLCKit.framework).起初一切都很好.然后我添加一些C++代码,所以一些文件是.mm文件.当我编译时,它失败了.Xcode日志
Undefined symbols for architecture armv7:
"std::runtime_error::runtime_error(std::string const&)", referenced from:
libebml::CRTError::CRTError(std::string const&, int) in MobileVLCKit(StdIOCallback.o)
"std::ostream& std::ostream::_M_insert<void const*>(void const*)", referenced from:
libebml::IOCallback::writeFully(void const*, unsigned long) in MobileVLCKit(IOCallback.o)
libebml::IOCallback::readFully(void*, unsigned long) in MobileVLCKit(IOCallback.o)
"std::runtime_error::runtime_error(std::string const&)", referenced from:
libebml::IOCallback::writeFully(void const*, unsigned long) in MobileVLCKit(IOCallback.o)
libebml::IOCallback::readFully(void*, unsigned long) in MobileVLCKit(IOCallback.o)
"VTT for std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >", referenced from:
...
Run Code Online (Sandbox Code Playgroud)
我不知道为什么以及如何解决这个问题.
我想点击UICollectionView的单元格,该单元格变为半透明。
- (void)collectionView:(UICollectionView *)collectionView
didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
GLEpisodeCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:[GLEpisodeCell identifier] forIndexPath:indexPath];//GLEpisodeCell is subclass of UICollectionViewCell
cell.alpha=0.5;
cell.contentView.alpha=0.5;
}
Run Code Online (Sandbox Code Playgroud)
但这是行不通的。细胞仍然不透明。
ios ×10
cocoa-touch ×6
objective-c ×4
c++ ×1
fmdb ×1
ios10 ×1
ios7 ×1
ipad ×1
iphone ×1
libvlc ×1
macos ×1
node.js ×1
react-native ×1
sprite-kit ×1
sqlite ×1
swift2.3 ×1
vlc ×1
webkit ×1
wkwebview ×1
xcode ×1