我有以下代码:
@implementation MyImageView
@synthesize image; //image is a UIImage
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
-(void) removeFromSuperview
{
self.image = nil;
[super removeFromSuperview];
}
- (void)drawRect:(CGRect)rect
{
// Drawing code
if (self.image)
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextClearRect(context, rect);
//the below 2 lines is to prove that the alpha channel of my UIImage is indeed drawn
//CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
//CGContextFillRect(context, rect);
CGContextDrawImage(context, self.bounds, self.image.CGImage);
}
}
@end
Run Code Online (Sandbox Code Playgroud)
当我运行代码时,我意识到我的视图的背景是黑色的。为了测试我的 UIImage …
我试图在 Ubuntu 服务器 13.0 和 python 2.7 中运行以下 python 代码
from twisted.python.log import err
from twisted.web.client import Agent
from twisted.internet import reactor
from twisted.internet.ssl import ClientContextFactory
from twisted.web.http_headers import Headers
from stringproducer import StringProducer
class WebClientContextFactory(ClientContextFactory):
def getContext(self, hostname, port):
return ClientContextFactory.getContext(self)
def display(response):
print "Received response"
print response
def main():
contextFactory = WebClientContextFactory()
agent = Agent(reactor, contextFactory)
d = agent.request("POST", "https://myweburl");
d.addCallbacks(display, err)
d.addCallback(lambda ignored: reactor.stop())
reactor.run()
if __name__ == "__main__":
main()
Run Code Online (Sandbox Code Playgroud)
当我尝试运行它时,它给了我以下错误:
ImportError: No module named twisted.web.client
Run Code Online (Sandbox Code Playgroud)
我曾在 …