How to Display an image through a NSBundle - nsbundle

I am trying to display a image when my method is activated. I have all the code down and I dont get any errors but the image just wont show.
Here is my Tweak.xm file.
#import <UIKit/UIKit.h>
#import <substrate.h>
#import <Foundation/Foundation.h>
#import <UIKit/UISaveToCameraRollActivity.h>
#import <UIKit/_UIImageViewExtendedStorage.h>
#import <UIKit/_UIOnePartImageView.h>
#import <UIKit/_UIPrefTableCellPiece.h>
#import <UIKit/_UIStretchableImage.h>
#import <UIKit/_UISwitchSlider.h>
#import <UIKit/_UITableViewCellDeleteConfirmationControl.h>
#import <UIKit/UIImage.h>
#import <UIKit/_UITableViewUpdateSupport.h>
#import <UIKit/UI9PartImageView.h>
#import <UIKit/UIAlertSheetTextField.h>
#import <UIKit/UIAutocorrectImageView.h>
#import <UIKit/UIClippedImageView.h>
#import <UIKit/UICompositeImageView.h>
#import <UIKit/UIImageAndTextTableCell.h>
#import <UIKit/UIImageView2.h>
#import <UIKit/UIOnePartImageView.h>
#import <UIKit/UITabBarSwappableImageView.h>
#import <UIKit/UITableViewCell2.h>
#import <UIKit/UITableViewCellEditControl.h>
#import <UIKit/UIThreePartImageView.h>
#define kBundlePath #"/Library/MobileSubstrate/DynamicLibraries/image.bundle"
%hook UISaveToCameraRollActivity
-(void)performActivity {
%orig;
NSBundle *bundle = [[NSBundle alloc] initWithPath:kBundlePath];
NSString *imagePath = [bundle pathForResource:#"pic" ofType:#"png"];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake (100, 200, 100, 100)];
imageView.image = [UIImage imageWithContentsOfFile:imagePath];
}
%end
and here is my MakeFile
include theos/makefiles/common.mk
TWEAK_NAME = test
test_FILES = Tweak.xm
test_FRAMEWORKS = UIKit
include $(THEOS_MAKE_PATH)/tweak.mk
BUNDLE_NAME = image
image_INSTALL_PATH = /Library/MobileSubstrate/DynamicLibraries
image_FRAMEWORKS = UIKit
include $(THEOS_MAKE_PATH)/bundle.mk
Thanks guys I really do appreciate all the help, and I know that i have a lot of headers but this project was many different things at one point. Please let me know just what is going on because like i said I dont even get any error codes. Thanks!

You're not actually adding the imageview to a superview: it's never making it into the render hierarchy and is therefore never displayed on the screen. My recommendation would be to find a particular view controller and stuff the view into its view, or to create your own toplevel UIWindow and display your image there.

Related

How to set custom font for foundation button

I am trying to set a custom font-family for the button in foundation 6 with no luck I am running foundation 6 with sass and believe they have removed the $button-font-family variable that was in previous versions. What is the best solution to achieve this without the variable?
Ideally I would like to apply a text-transform on the button text as well which is also not a button variable in the _setting.sass foundation file. As you may have gathered I am very new to foundation and sass so any help would be greatly appreciated.
It doesn't look like a font-family is specified in scss/components/_button.scss and that's where button syles are defined. The $body-font-family is set in both scss/settings/_settings.scss as well as scss/_global.scss (if not already defined in _settings.scss). So, verify that you have updated the value of $body-font-family there.
Aside from that, if you are using foundation sass semantically (i.e. mixins), you should be able to use the button mixin like so:
#include button( false, #ebebeb, #a5a5a5, black, solid );
..and then set the font-family property after the mixin like you normally would.
----Update: Based on follow up question/comment----
Here's an example main sass file for one of the foundation sites I'm working on now.
// Author copy of Foundation settings/_settings.scss
#import "settings";
// Author copy of Foundation _globals.scss
#import "global";
// Import from Foundation
#import "path/to/foundation-sites/scss/grid/grid";
#import "path/to/foundation-sites/scss/typography/typography";
#import "path/to/foundation-sites/scss/components/button";
// Include Foundation classes/styles that we want to use
#include foundation-global-styles();
#include foundation-typography();
//
// Author Variables
//
$color-map : ( 'blue': #40578a, 'blue-tint': #7e8ba8, 'blue-shade': #364a75, 'dark': #3d3e41, 'silver': #bdc0c6, 'gold': #ab883c );
$blue : map-get($color-map, 'blue');
$blue-tint : map-get($color-map, 'blue-tint');
$blue-shade: map-get($color-map, 'blue-shade');
$dark : map-get($color-map, 'dark');
$silver : map-get($color-map, 'silver');
$gold : map-get($color-map, 'gold');
//
// Author Components
//
#import "common";
#import "btn";
#import "view";
#import "cover";
#import "header";
#import "hero";
#import "navbar";
#import "main";
#import "page";
#import "intro";
#import "services";
I'll go through this section by section. It's pretty simple and once you have a project set up this way, you'll love it.
// Author copy of Foundation settings/_settings.scss
Here, we are importing a copy of the Foundation _settings.scss file and modifying it for our needs. Don't mess with the original _settings file that ships with Foundation. Doing so will make it more difficult to update the library moving forward.
// Author copy of Foundation _globals.scss
Same concept as the _settings file.
// Import from Foundation
These imports are the only parts of the Foundation framework that I want to use in this case. These component files include the mixins used to generate these components. This allows us to use the mixins semantically in our code.
// Include Foundation classes/styles that we want to use
And this will output the pre-defined classes/styles that we want to use from foundation. Typically, you will at least want to include global and typography styles.
// Author Variables
This is where I put my custom variables (not related to Foundation). You could put this in another partial if you want - just a preference.
// Author components
These are the project's custom components which may or may not utilize Foundation's mixins. The point is, we can if we want to now that we have included the components/mixins we want to use.
So, in your case, you could simply do this:
// Foundation settings
#import "settings";
// Foundation globals
#import "global";
// Import from Foundation
#import "../path/to/foundation-sites/scss/components/button";
//
// Author Variables
//
$special-button-font: Georgia, serif;
.special-button {
#include button(false, #ebebeb, #a5a5a5, black, solid);
font-family: $special-button-font;
&.tiny { font-size: map-get($button-sizes, tiny); }
&.small { font-size: map-get($button-sizes, small); }
&.large { font-size: map-get($button-sizes, large); }
&.expanded { #include button-expand; }
}

LESS - Mixin as variable argument

I'm importing bootstrap files and rewriting the source variables, eg :
#import "./../../../../vendor/bootstrap/less/scaffolding.less";
#import "./../../../../vendor/bootstrap/less/type.less";
#import "./../../../../vendor/bootstrap/less/code.less";
#import "./../../../../vendor/bootstrap/less/grid.less";
#import "./../../../../vendor/bootstrap/less/tables.less";
#import "./../../../../vendor/bootstrap/less/forms.less";
#import "./../../../../vendor/bootstrap/less/buttons.less";
//etc ...
#font-size-base: 100%;
Then in my own variables.less I set something like that, a mixin for rem font sizing
.font-size(#sizeValue) {
#remValue: #sizeValue;
#pxValue: (#sizeValue * 10);
font-size: ~"#{pxValue}px";
font-size: ~"#{remValue}rem";
}
Now of course, I dont see how I can make that working, this is what I wanted, and it doesn't work (input not recognised) :
// In bootstrap import file, trying to overwrite their variable parameter with my mixin
#font-size-h2: .font-size(32);
Any way to do what I want ?

linear-gradient not a string for `str-slice') in bourbon

While I was creating theme with Bourbon, I got the error below:
error sass/screen.scss (Line 18 of sass/bourbon/css3/_background.scss: \
$string: linear-gradient(10deg, #217142,#214271) is not a string for `str-slice')
Here's code in _background.scss, as it's on its Github repo:
#mixin background($backgrounds...) {
$webkit-backgrounds: ();
$spec-backgrounds: ();
#each $background in $backgrounds {
$webkit-background: ();
$spec-background: ();
$background-type: type-of($background);
#if $background-type == string or list {
$background-str: if($background-type == list, nth($background, 1), $background);
# line 18 just below:
$url-str: str-slice($background-str, 0, 3);
$gradient-type: str-slice($background-str, 0, 6);
#if $url-str == "url" {
$webkit-background: $background;
$spec-background: $background;
}
}
}
}
I was using Sass 3.3.14 & Compass 1.0.0.rc.1 to create the theme in order to get full benefits of bourbon.
UPDATE:
(Oops, I've forgotten telling about Neat or Bitters. I am using them, too. Sorry.)
I've updated files as being described on Bitters' guide on Github:
#import 'compass';
#import 'bourbon/bourbon';
#import 'base/grid-settings';
#import 'neat/neat';
#import 'base/base';
#import 'custom/custom';
But same error occurs.
I've got similar error
error (Line 18 of bourbon/css3/_background.scss: $string: linear-gradient(#c73b3c,#b8201f) is not a string for `str-slice')
when added the #import 'compass'; in a working bourbon/neat/bitters environment. removing it fixed the problem. importing after thoughtbot's libraries gives bunch of warnings instead of errors but working.
#import 'bourbon/bourbon';
#import 'base/grid-settings';
#import 'neat/neat';
#import 'base/base';
#import 'custom/custom';
#import 'compass';
The problem seems to be related to the $base-line-height variable.
In compass $base-line-height set to $base-line-height 24px;
In bourbon $base-line-height set to $base-line-height: 1.5;
when compass loaded after bourbon you get a WARNING: $base-line-height must resolve to a pixel unit.
because bourbon set it to 1.5.
If you try to add $base-line-height: 24px; before the #import 'compass'; command you get error:
(Line 36 of /usr/local/lib/ruby/gems/2.1.0/gems/compass-core-1.0.1/stylesheets/compass/typography/_vertical_rhythm.scss: Incompatible units: 'em' and 'px'.)
because $base-font-size is also conflicting between the libraries.
A solution I found is to set the imports like this:
#import 'bourbon/bourbon';
#import 'base/grid-settings';
#import 'neat/neat';
#import 'base/base';
#import 'custom/custom';
$base-font-size: 16px;
$base-line-height: 24px;
#import 'compass';
Now you have both playing together. I couldn't make it to work other way around where compass is imported before bourbon. I guess this conflict should be fixed at libraries level (bourbon?).

SASS: Can't Share Variables Between Files

I've got a file called app.scss, inside that file I'm making four #imports:
#import "settings";
#import "foundation";
#import "type";
#import "custom";
I'm defining a $main-color variable like this in settings.scss:
$main-color: blue;
But for some reason when I reference that file in custom.scss, I get an error:
body {
background-color: $main-color;
}
Any idea what might be causing this problem? Thanks in advance!
You should rename settings.scss/custom.scss to _settings.scss/_custom.scss.

CSS zurb foundation and dhtmlx

I have a project that requires zurb foundation css and dhtml scheduler and the css is not playing very nicely.
There are two issues in particular.
The monthly calendar is misaligned because of the .56em .62em padding on the table.
A bit more complicated is the appointments on the calender.
this is what it looks like. notice the hole in the side menu.
The styles by default that are the problem.
And I need to remove them to properly render the page.
We are using scss version of foundation but I'm not very familiar with its capabilities and the dhtmlx controls do not use it.
So my basic question is how should i change these styles with the least amount of impact to foundation or dhtml?
I'm sure I could use java script but I think that would be a pain as the calender changes having to find all the elements to apply styles again, and i'm really hopping there is a nifty css trick. =)
Thanks!
******* EDIT ***********
The table issue was quickly fixed for chrome and IE by adding another style sheet after foundation to override the conflicting styles. Short and simple.
<style type="text/css" media="screen">
#scheduler_here table tr td, #scheduler_here table tr th
{
padding: 0;
}
#scheduler_here *, #scheduler_here *:before, #scheduler_here *,after {
box-sizing: content-box;
-webkit-box-sizing: content-box;
}
</style>
If you use Foundation 4 (F4) you can pick and choose which parts of foundation CSS are generated by Compass / Sass. Don't forget to run compass compile after you make the change.
edit -> sass/app.scss
// Global Foundation Settings
#import "settings";
// Comment out this import if you are customizing you imports below
// #import "foundation";
// Import specific parts of Foundation by commenting the import "foundation"
// and uncommenting what you want below. You must uncomment the following if customizing
#import "foundation/components/global"; // *always required
#import "foundation/components/grid";
#import "foundation/components/visibility";
#import "foundation/components/block-grid";
#import "foundation/components/type";
#import "foundation/components/buttons";
#import "foundation/components/forms"; // *requires components/buttons
#import "foundation/components/custom-forms"; // *requires components/buttons, components/forms
#import "foundation/components/button-groups"; // *requires components/buttons
#import "foundation/components/dropdown-buttons"; // *requires components/buttons
#import "foundation/components/split-buttons"; // *requires components/buttons
#import "foundation/components/flex-video";
#import "foundation/components/section";
#import "foundation/components/top-bar"; // *requires components/grid
#import "foundation/components/orbit";
#import "foundation/components/reveal";
#import "foundation/components/joyride";
#import "foundation/components/clearing";
#import "foundation/components/alert-boxes";
#import "foundation/components/breadcrumbs";
#import "foundation/components/keystrokes";
#import "foundation/components/labels";
#import "foundation/components/inline-lists";
#import "foundation/components/pagination";
#import "foundation/components/panels";
#import "foundation/components/pricing-tables";
#import "foundation/components/progress-bars";
#import "foundation/components/side-nav";
#import "foundation/components/sub-nav";
#import "foundation/components/switch";
#import "foundation/components/magellan";
// #import "foundation/components/tables"; // prevent Table CSS from loading
#import "foundation/components/thumbs";
#import "foundation/components/tooltips";
#import "foundation/components/dropdown";
Another option, if you know how you would like to change the padding, borders, etc. to match your other included elements is you could edit the _settings.scss, lines 1064 - 1097 where it has variables for tables. I am showing the variables here unmodified to illustrate what can be changed.
//
// Table Variables
//
//// Background color for the table and even rows
// $table-bg: #fff;
// $table-even-row-bg: #f9f9f9;
//// Table cell border style
// $table-border-style: solid;
// $table-border-size: 1px;
// $table-border-color: #ddd;
//// Table head styles
// $table-head-bg: #f5f5f5;
// $table-head-font-size: emCalc(14px);
// $table-head-font-color: #222;
// $table-head-font-weight: bold;
// $table-head-padding: emCalc(8px) emCalc(10px) emCalc(10px);
//// Row padding and font styles
// $table-row-padding: emCalc(9px) emCalc(10px);
// $table-row-font-size: emCalc(14px);
// $table-row-font-color: #222;
// $table-line-height: emCalc(18px);
//// Display and margin of tables
// $table-display: table-cell;
// $table-margin-bottom: emCalc(20px);
If you have time and want to go even further, you can pull the foundation/components/tables.scss file into your local project, modify it however you like and link to the modified version as above. You can find the original files by running gem which zurb-foundation I have installed with rvm so I get something like ~/.rvm/gems/ruby-1.9.3-p286/gems/zurb-foundation-4.1.5/lib/zurb-foundation.rb from the zurb-foundation-4.1.5 directory the file is located in scss/foundation/components and called _tables.scss

Resources