我知道我可以这样做,以确保python中的选项卡完成效果.
import readline
COMMANDS = ['extra', 'extension', 'stuff', 'errors',
'email', 'foobar', 'foo']
def complete(text, state):
for cmd in COMMANDS:
if cmd.startswith(text):
if not state:
return cmd
else:
state -= 1
readline.parse_and_bind("tab: complete")
readline.set_completer(complete)
raw_input('Enter section name: ')
Run Code Online (Sandbox Code Playgroud)
我现在对使用目录完成制表符感兴趣.(/ home/user/doc>标签)
我怎么去做这样的任务?
如何使用CGRectIntegral函数?我理解它的目的.
该文件是不是它的确切用途明确.
1 import subprocess
2 raw = raw_input("Filename:").lower()
3 ip = raw_input("Host:").lower()
4 cmd = subprocess.call("tcpdump -c5 -vvv -w" + " raw " + " ip ",shell=True)
Run Code Online (Sandbox Code Playgroud)
所以这是我的剧本.除了一个关键目标,我使用原始输入一切正常.它允许我输入我想要的任何东西,但是当它用于保存文件或使用ip/host时,doe实际上并没有做任何事情.当然它给了我数据包,但是从localhost而不是我输入的主机.
我怎么知道这不起作用是因为我的第一个原始输入是文件名,所以我放入测试,当我在文件夹中查看我的脚本是,它产生一个名为"raw"的文件意思,它实际上并没有带我的输入只使用我的"X"内的什么...
所以我有机会来到这个:
1 import subprocess
2 raw = raw_input("Filename:").lower()
3 ip = raw_input("Host:").lower()
4 cmd = subprocess.call("tcpdump -c5 -vvv -w" + raw + "host" + ip,shell=True)
Run Code Online (Sandbox Code Playgroud)
这很好,因为它实际上需要-w但它现在将其保存为rawhostip而不是"raw"输入.作为参考,这是该命令在终端中的样子:
tcpdump -c5 -vvv -w savename host wiki2
Run Code Online (Sandbox Code Playgroud)
只有两个变量是savename和wiki2,其余的变量需要命令才能工作.
使用此脚本我收到此错误:
import subprocess
raw = raw_input("Filename:").lower()
ip = raw_input("Host:").lower()
cmd = subprocess.call("tcpdump -c5 -vvv -w" + raw, "host" …
Run Code Online (Sandbox Code Playgroud) 我想学习自定义android启动器,我不知道如何开始,你能给我一些建议,一些博客链接或其他例子等等.
我正在尝试建立一个非常简单的视频播放器.(iOS 5.1,Xcode 4.3.1)
-(void)playMedia {
NSString *movieFile = [[NSBundle mainBundle] pathForResource:@"Movie" ofType:@"m4v"];
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:movieFile]];
[moviePlayer prepareToPlay];
moviePlayer.view.frame = self.view.bounds;
moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
moviePlayer.movieSourceType = MPMovieSourceTypeFile;
moviePlayer.fullscreen = YES;
moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
[self.view addSubview: moviePlayer.view];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playMediaFinished:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
[moviePlayer play];
}
Run Code Online (Sandbox Code Playgroud)
它在调用时工作正常,但它只播放四秒钟,然后出现黑屏.如果我在播放期间点按屏幕,它将播放整个序列.如果我停止点击屏幕四秒钟,则会出现黑屏.
我错过了什么?
库尔特
编辑版很好.
在接口文件中:
@property (nonatomic,strong) MPMoviePlayerController *myMovieController;
Run Code Online (Sandbox Code Playgroud)
在.m文件中:
-(void)playMedia {
NSString *movieFile = [[NSBundle mainBundle] pathForResource:@"Movie" ofType:@"m4v"];
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:movieFile]];
[moviePlayer prepareToPlay];
moviePlayer.view.frame = self.view.bounds;
moviePlayer.scalingMode …
Run Code Online (Sandbox Code Playgroud) 我想在我的新Sprite Kit游戏中制作一个水平滚动菜单.Sprite Kit相当新,但Sprite Kit的教程并不多.UIScrollView与Sprite Kit兼容吗?我尝试了几种这样的方法:
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
scroll.pagingEnabled = YES;
NSInteger numberOfViews = 3;
for (int i = 0; i < numberOfViews; i++) {
CGFloat xOrigin = i * self.view.frame.size.width;
UIView *awesomeView = [[UIView alloc] initWithFrame:CGRectMake(xOrigin, 0, self.view.frame.size.width, self.view.frame.size.height)];
awesomeView.backgroundColor = [UIColor colorWithRed:0.5/i green:0.5 blue:0.5 alpha:1];
[scroll addSubview:awesomeView];
}
Run Code Online (Sandbox Code Playgroud)
这没用.我之前从未使用过UIScrollView.任何人都可以使用UIScrollView制作水平滚动菜单吗?我想要做的一个例子是Bloons TD 5及其菜单.
menu uiscrollview horizontal-scrolling horizontalscrollview sprite-kit
如何让我的应用程序使用iOS 7后台更新功能?我注意到一些应用程序已经这样做了,但它似乎并不是全自动的.
我正在调整我的应用程序到iOS 7,当我阅读文档时,我在此链接下的popoverArrowDirection下读了这一行:
"(已弃用.弹出窗口在iOS 7及更高版本中不使用箭头.)"
这很奇怪,因为我的popover似乎在iOS 7中仍然有箭头.我只是错误地理解这个吗?
/* Adding the Path */
UserGraphBuff = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(UserGraphBuff,5,10,0,1);
CGContextSetLineWidth(UserGraphBuff, 2 );
CGContextBeginPath(UserGraphBuff);
//line to last user point
CGContextAddLineToPoint(UserGraphBuff, (*xVal)[sizeof xVal / sizeof *xVal - 1], (*yNewVal)[sizeof yNewVal / sizeof *yNewVal - 1]);
//line to rest of user points in reverse order
for (int i = sizeof xVal / sizeof *xVal - 1; i > -1; i--){
CGContextAddLineToPoint(UserGraphBuff, (*xVal)[i], (*yNewVal)[i]);
}
//EOFill
CGContextEOFillPath(UserGraphBuff);
Run Code Online (Sandbox Code Playgroud)
以上是我正在努力解决的代码.它应该做CGContext所说的那样,但我没有得到任何东西. 我一直收到这个错误:
Fri Oct 28 13:18:40 case.app testApplication[4127] <Error>: CGContextSetRGBStrokeColor: invalid context 0x0
Fri Oct 28 13:18:40 …
Run Code Online (Sandbox Code Playgroud) 我需要在iOS5上使用YouTube的API创建的HTML5播放器上播放VEVO视频.
https://developers.google.com/youtube/iframe_api_reference
目前我可以播放普通视频而不会出现故障.但是当我尝试播放VEVO视频时,它说"内容无法在YouTube之外播放".是否有任何合法的方式来解决这个问题?
我已经尝试将播放器的"origin"属性设置为我的域名.这没有帮助.
这是来自上述链接的示例,其中设置了原点
<iframe id="player" type="text/html" width="640" height="390"
src="http://www.youtube.com/embed/M7lc1UVf-VE?enablejsapi=1&origin=http://example.com"
frameborder="0"></iframe>
Run Code Online (Sandbox Code Playgroud)
如果有人知道合法播放VEVO内容的任何其他方式,请告诉我.:).任何法律漏洞也会:D.
ios ×3
objective-c ×2
python ×2
android ×1
cgcontext ×1
cocoa-touch ×1
html5-video ×1
ios7 ×1
iphone ×1
launcher ×1
menu ×1
quartz-2d ×1
raw-input ×1
sprite-kit ×1
subprocess ×1
tcpdump ×1
uikit ×1
uiscrollview ×1
xcode ×1
youtube-api ×1